배우기
엔진 클래스
TextService
만들 수 없음
서비스
복제되지 않음

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.


요약
메서드
FilterAndTranslateStringAsync(stringToFilter: string,fromUserId: number,targetLocales: {any},textContext: Enum.TextFilterContext):TextFilterTranslatedResult
사용되지 않음
FilterStringAsync(stringToFilter: string,fromUserId: number,textContext: Enum.TextFilterContext):TextFilterResult
GetFamilyInfoAsync(assetId: ContentId):Dictionary
GetTextSize(string: string,fontSize: number,font: Enum.Font,frameSize: Vector2):Vector2
상속된 멤버

API 참조
메서드
FilterAndTranslateStringAsync
사용되지 않음

FilterStringAsync
생성
기능: UI
TextService:FilterStringAsync(
stringToFilter:string, fromUserId:number, textContext:Enum.TextFilterContext
매개 변수
stringToFilter:string
fromUserId:number
기본값: "PrivateChat"
코드 샘플
애완동물 이름 필터 예제
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextService = game:GetService("TextService")
local Players = game:GetService("Players")
local Remotes = Instance.new("Folder")
Remotes.Name = "PetNamingRemotes"
Remotes.Parent = ReplicatedStorage
local UserNamedPet = Instance.new("RemoteEvent")
UserNamedPet.Name = "UserNamedPet"
UserNamedPet.Parent = Remotes
local SendPetName = Instance.new("RemoteEvent")
SendPetName.Name = "SendPetName"
SendPetName.Parent = Remotes
local RequestAllPetNames = Instance.new("RemoteFunction")
RequestAllPetNames.Name = "RequestAllPetNames"
RequestAllPetNames.Parent = Remotes
local filterResults = {}
local function broadcastPetName(userId)
local filterResult = filterResults[userId]
if filterResult then
for _, player in pairs(Players:GetPlayers()) do
if player then
-- 업데이트를 방해하지 않도록 새로운 스레드에서 실행
task.spawn(function()
-- 이 사용자의 필터링된 문자열을 가져옴
local toUserId = player.UserId
local filteredString = filterResult:GetNonChatStringForUserAsync(toUserId)
filteredString = filteredString or ""
SendPetName:FireClient(player, userId, filteredString)
end)
end
end
end
end
UserNamedPet.OnServerEvent:Connect(function(player, petName)
local fromUserId = player.UserId
-- 에러를 잡기 위한 pcall
local success, result = pcall(function()
return TextService:FilterStringAsync(petName, fromUserId)
end)
if success then
filterResults[fromUserId] = result
broadcastPetName(fromUserId)
else
print("애완동물 이름을 필터링할 수 없습니다.")
end
end)
RequestAllPetNames.OnServerInvoke = function(player)
local toUserId = player.UserId
local petNames = {}
-- 필터 결과를 통해 전송할 애완동물 이름을 필터링
for fromUserId, filterResult in pairs(filterResults) do
local filteredString = filterResult:GetNonChatStringForUserAsync(toUserId)
filteredString = filteredString or ""
-- remote function으로 전송할 수 없도록 userId를 문자열로 변환해야 함
petNames[tostring(fromUserId)] = filteredString
end
return petNames
end
Players.PlayerRemoving:Connect(function(oldPlayer)
local userId = oldPlayer.UserId
filterResults[userId] = nil
end)

GetFamilyInfoAsync
생성
기능: UI
TextService:GetFamilyInfoAsync(assetId:ContentId):Dictionary
매개 변수
assetId:ContentId
코드 샘플
폰트 패밀리 정보 가져오기
local TextService = game:GetService("TextService")
local familyToCheck = "rbxasset://fonts/families/Arimo.json"
local success, info = pcall(function()
return TextService:GetFamilyInfoAsync(familyToCheck)
end)
if success then
print("폰트 이름:", info.Name)
print("모양들:")
for _, face in info.Faces do
print("--------")
print("이름:", face.Name)
print("두께:", face.Weight.Name)
print("스타일:", face.Style.Name)
end
end

GetTextBoundsAsync
생성
기능: UI
TextService:GetTextBoundsAsync(params:GetTextBoundsParams):Vector2
매개 변수
반환
코드 샘플
텍스트 크기 측정
local TextService = game:GetService("TextService")
-- 매개변수 선언
local params = Instance.new("GetTextBoundsParams")
params.Text = "안녕 세상!"
params.Font = Font.new("rbxasset://fonts/families/GrenzeGotisch.json", Enum.FontWeight.Thin)
params.Size = 20
params.Width = 200
local success, bounds = pcall(function()
return TextService:GetTextBoundsAsync(params)
end)
if success then
print(bounds)
end

GetTextSize
기능: UI
TextService:GetTextSize(
string:string, fontSize:number, font:Enum.Font, frameSize:Vector2
매개 변수
string:string
fontSize:number
frameSize:Vector2
반환
코드 샘플
텍스트 크기 가져오기
local TextService = game:GetService("TextService")
local function getTextBounds()
local message = "안녕하세요, 세상!"
local size = Vector2.new(1, 1)
local bounds = TextService:GetTextSize(message, 12, "SourceSans", size)
return bounds
end
print(getTextBounds())

GetTextSizeOffsetAsync
생성
기능: UI
TextService:GetTextSizeOffsetAsync(
fontSize:number, font:Font
매개 변수
fontSize:number
font:Font
반환
코드 샘플
텍스트 크기 오프셋 가져오기
local TextService = game:GetService("TextService")
local label = script.Parent.TextLabel
-- 플레이어의 선호 텍스트 크기 설정에 맞게 조정된 오프셋 가져오기
local success, offset = pcall(function()
return TextService:GetTextSizeOffsetAsync(label.TextSize, label.FontFace)
end)
if success then
-- 오프셋을 추가하여 레이블의 핵심 높이 조정
label.Size = UDim2.fromOffset(label.Size.X.Offset, label.Size.Y.Offset + offset)
end

©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.