In my game, I am using text chat service. I am trying to add a leave/join message inside the game. I have made it so that when I join or leave the game, it says I joined or left in a different color, however, when I joined the game, nothing gets sent in the chat. The weird thing is, there are no errors in the output console. This is what I have tried.
SERVER
local remoteEvent = game:GetService("ReplicatedStorage").JoinLeaveRE game.Players.PlayerAdded:Connect(function(plr) if (plr.UserId == 1274540012) then remoteEvent:FireAllClients(plr,"[OWNER] "..plr.Name.." joined the game!") else remoteEvent:FireAllClients(plr,plr.Name.." joined the game.") end end) game.Players.PlayerRemoving:Connect(function(plr) if (plr.UserId == 1274540012) then remoteEvent:FireAllClients(plr,"[OWNER] "..plr.Name.." left the game.") else remoteEvent:FireAllClients(plr,plr.Name.." left the game.") end end)
CLIENT
local remoteEvent = game:GetService("ReplicatedStorage").JoinLeaveRE local chat = game:GetService("TextChatService") local channel = chat:WaitForChild("TextChannels"):WaitForChild("RBXGeneral") remoteEvent.OnClientEvent:Connect(function(plr,message) channel:DisplaySystemMessage("<font color='#04D9FF'>"..message.."</font>") print("PLEASE WORK") end) -- #04D9FF
Try using RBXSystem instead of RBXGeneral.
Client
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("JoinLeaveRE") local chat = game:GetService("TextChatService") local channel = chat:WaitForChild("TextChannels"):WaitForChild("RBXSystem") remoteEvent.OnClientEvent:Connect(function(plr,message) channel:DisplaySystemMessage("<font color='#04D9FF'>"..message.."</font>") print("PLEASE WORK") end) -- #04D9FF
I figured it out on my own. I just simply added a task.wait(.5)
inside OnClientEvent