사용자 정의 텍스트 채팅 명령어

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

TextChatService는 다른 플레이어 음소거, 아바타 이모티콘 사용 등 일반적인 용도를 위한 내장 채팅 명령어를 제공합니다. Studio의 속성 창에서 CreateDefaultCommandstrue로 설정하여 이를 활성화할 수 있습니다.

또한 TextChatCommand를 사용하여 사용자 정의 명령어를 추가할 수 있습니다. 채팅 입력창에 정의된 명령어를 입력한 사용자는 TextChatCommand.Triggered로 정의된 콜백을 트리거하여 사용자 지정 작업을 수행하게 됩니다.

다음 예시는 플레이어가 /super 또는 /mini를 입력할 때 캐릭터의 크기를 증가 또는 감소시킬 수 있는 채팅 명령어를 만드는 방법을 보여줍니다.

  1. TextChatService 안에 TextChatCommand 인스턴스를 추가합니다.

  2. 이름을 SizeCommand로 바꿉니다.

  3. PrimaryAlias 속성을 /super로 설정하고, SecondaryAlias/mini로 설정합니다.

  4. 채팅 명령어의 콜백을 정의하여 캐릭터의 크기를 조정하는 다음 ScriptServerScriptService 안에 삽입합니다:

    Script

    local TextChatService = game:GetService("TextChatService")
    local Players = game:GetService("Players")
    local sizeCommand: TextChatCommand = TextChatService:WaitForChild("SizeCommand")
    sizeCommand.Triggered:Connect(function(textSource, message)
    local scaleMult = 1
    local messageWords = string.split(message, " ")
    if messageWords[1] == "/super" then
    scaleMult = 2
    elseif messageWords[1] == "/mini" then
    scaleMult = 0.5
    end
    local player = Players:GetPlayerByUserId(textSource.UserId)
    if player then
    local character = player.Character
    if character then
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
    for _, child in humanoid:GetChildren() do
    if child:IsA("NumberValue") then
    child.Value *= scaleMult
    end
    end
    end
    end
    end
    end)
©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.