how i do whisper command using a chatspeaker?
how i do whisper command using a chatspeaker
I tried this:
01 | local Chat = game:GetService( "Chat" ) |
02 | local plrs = game:GetService( "Players" ) |
03 | local serverScriptService = game:GetService( "ServerScriptService" ) |
04 | local chatServiceModule = require(serverScriptService:WaitForChild( "ChatServiceRunner" ).ChatService) |
06 | local ReplicatedModules = Chat:WaitForChild( "ClientChatModules" ) |
07 | local ChatModules = Chat:WaitForChild( "ChatModules" ) |
08 | local ChatConstants = require(ReplicatedModules:WaitForChild( "ChatConstants" )) |
09 | local speaker = chatServiceModule:AddSpeaker( "ROBLOX" ) |
14 | ", i like you the way you are" |
16 | speaker:JoinChannel( "All" ) |
17 | speaker:SetExtraData( "NameColor" , Color 3. new( 0 , 132 , 255 )) |
18 | speaker:SayMessage( "I am fake, sorry :(" ) |
19 | speaker:SayMessage ( "You can say: !message and i will send you a message :)" ) |
21 | serverScriptService:WaitForChild( "ChatServiceRunner" ).ChatService:Clone().Parent = workspace |
22 | for i, v in pairs (chatServiceModule:GetChannelList()) do |
26 | local function GetWhisperChannelPrefix() |
27 | if ChatConstants.WhisperChannelPrefix then |
28 | return ChatConstants.WhisperChannelPrefix |
33 | function GetWhisperChannelId(userName) |
34 | return GetWhisperChannelPrefix() .. userName |
38 | local function plr_chatted(player, message) |
39 | if string.lower(message) = = "!message" then |
40 | local number = table.getn(messages) |
41 | local random = math.random( 1 , number) |
42 | local channelObj = GetWhisperChannelId(player.Name) |
43 | if channelObj = = nil then warn( "Erro: canal não encontrado!" ) return end |
44 | speaker:JoinChannel(channelObj.Name) |
45 | speaker:SayMessage(messages [ random ] ) |
47 | speaker:JoinChannel( "All" ) |
50 | for i, player in pairs (plrs:GetPlayers()) do |
51 | player.Chatted:Connect( function (message) |
52 | plr_chatted(player, message) |
54 | speaker:SayMessage( "Hi " ..player.Name.. "!" ) |
57 | plrs.PlayerAdded:Connect( function (player) |
58 | speaker:SayMessage( "Hi " ..player.Name.. "!" ) |
https://pastebin.com/2m5uVPfS