TextChatService에는 다른 플레이어를 음소거하고 아바타 감정 표현을 사용하는 등 일반적인 목적을 위한 내장 채팅 명령이 있습니다.Studio의 CreateDefaultCommands 창에서 true 로 설정하여 활성화할 수 있습니다.
또한 TextChatCommand를 사용하여 사용자 지정 명령을 추가할 수 있습니다.채팅 입력 바에서 정의된 명령을 보내는 사용자는 TextChatCommand.Triggered에 의해 정의된 콜백을 트리거하여 사용자 지정 작업을 수행합니다.
다음 예제에서는 플레이어가 /super 또는 /mini를 입력할 때 캐릭터의 크기를 늘리거나 줄일 수 있는 채팅 명령을 만드는 방법을 보여줍니다.
내부에 TextChatCommand 인스턴스를 추가하십시오 TextChatService .
이름을 크기 명령 으로 바꿉니다.
속성 PrimaryAlias 을 /super 로 설정하고 속성 SecondaryAlias 을 /mini 로 설정합니다.
다음 Script 를 내부에 ServerScriptService 에 삽입하여 문자 크기를 조정하는 채팅 명령의 콜백을 정의합니다:
스크립트local TextChatService = game:GetService("TextChatService")local Players = game:GetService("Players")local sizeCommand: TextChatCommand = TextChatService:WaitForChild("SizeCommand")sizeCommand.Triggered:Connect(function(textSource, message)local scaleMult = 1local messageWords = string.split(message, " ")if messageWords[1] == "/super" thenscaleMult = 2elseif messageWords[1] == "/mini" thenscaleMult = 0.5endlocal player = Players:GetPlayerByUserId(textSource.UserId)if player thenlocal character = player.Characterif character thenlocal humanoid = character:FindFirstChildWhichIsA("Humanoid")if humanoid thenfor _, child in humanoid:GetChildren() doif child:IsA("NumberValue") thenchild.Value *= scaleMultendendendendendend)