I made a script which should send a system message in the chat (TextChatService) for everyone to see, however it’s only showing the message to the local player.
Code: (not full)
Client:
CreateMsg:FireServer()
local msgEvent
local function sendMsgToChat(player, message)
task.wait()
Channel:DisplaySystemMessage("<font color='#41CD50'>"..message.." completed bla bla bla"</font>")
msgEvent:Disconnect()
end
msgEvent = sendMsg.OnClientEvent:Connect(sendMsgToChat)
CreateMsg:FireServer()
local function sendMsgToChat(player, message)
task.wait()
Channel:DisplaySystemMessage("<font color='#41CD50'>"..message.." completed bla bla bla"</font>")
end
sendMsg.OnClientEvent:Connect(sendMsgToChat)
The reason why I disconnect the event is to prevent the RemoteEvents from stacking. I did try your code tho, what happened was that after the 1st time the event was fired, 1 message was sent in the chat, after the 2nd time, 2 messages were sent into the chat. It also didn’t fix the issue that only the local player would see it. Ty anyways!
I think you should keep the sendMsg connected the whole time, if not then how each client would receive the FireAllClients from that event?
If you dont want the messages to be stacked, or you use a debouce in server to just allow one message each x seconds, or create a queue system in client or in server to display messages in order
Sorry? FireAllClients() to disconnect all clients from server? Its just to fire a remote to all clients in server, not to disconnect them, or you mean, OP should use it to disconnect the remote?.. i dont get it…
You can send any amount of values when using the remote and FireAllClients().
Only FireClient(player), is the one that matters in which the first argument is the important one, for FireAllClients(true, false, player, part, stuff, etc) can be used, idk why OP is sending the player as first argument, maybe cause OP needs the player that triggered the message as first argument.
As shown in OP’s function: sendMsgToChat(player, message)
So FireAllClients(player, player.DisplayName) player is the player, and DisplayName is the “message”
The script which created the message (sendMsgToChat) was inside another function, which was inside a deactivated script. I moved it outside in a seperate script
Disconnecting the event was completely useless, as the bug which sent multiple messages the more often the RemoteEvent was used fixed itself now?
local function sendMsgToChat(player, message)
task.wait()
Channel:DisplaySystemMessage("<font color='#41CD50'>"..message.." clicked a button lol</font>")
end
sendMsg.OnClientEvent:Connect(sendMsgToChat)