How do I make a system message server-sided?

So, I wanted to make a “Player has been killed” in the chat, as a system message sort of thing. I tried using game:GetService('StarterGui'):SetCore in scripts, but it told me that you cannot use that in a script. So, I tried it in a localscript, and it worked. But, it was client-sided. How do I make it so it is server-sided?

Thanks Vaelkarr.

1 Like

You can’t.

If you are making a kill feed, just use a remote event to fire to all clients that a player was killed.

So like this?

Server :

script.Parent.Parent.Remotes.MessageSendServer:FireAllClients({
Text = "[Server]: "..player.." has been killed!";
})
end)

Client :

script.Parent.Parent.Parent.Remotes.MessageSendServer.OnClientEvent:Connect(function(cp)
game:GetService("StarterGui"):SetCore('ChatMakeSystemMessage', cp)
end)

As inxapaxx said, you can’t. This is because the server can’t check if a property has changed in EVERY player at all times, and even if it could it would get overloaded pretty fast considering how basically every second a player’s property changes. And yes, a remote function is the way to go. Fire it once the humanoid health is 0, and then from there have the server display the player’s name along with “has been killed!”

I did test it with my friend, he saw nothing in the chat, but I saw it. Is this how FireAllClients work?

1 Like

Are you using FireAllClients from the client side, or from the server side after the client fires the server?

Scratch that, FireAllClients isn’t needed. Just do something along the lines of:

-- this is the when the server is fired line, make sure to include the player as data when firing the server. I'll use deadPlayer as an example
for _, player in pairs(game.Players:GetPlayers()) do
local deathPopup = (path to the textlabel that you will use to show that a player died)
deathPopup.Visible = true (set it to false at the start of the game)
deathPopup.Text = deadPlayer.Name.. "has been killed!"

edit; oops, forgot to add .Name at the end of deadPlayer

Well, um. I meant inside the chat, not a text label. Is there a way to do it in the chat with everyone in the universe seeing it?

1 Like

Oh… I see. Unfortunately I myself am still fairly new to scripting and haven’t messed around with the chat yet, but I’ll let you know if I find a solution.

Oh I see. In this case, FireAllClients could be used then. Within the remoteFunction table, specify the player name and the text you want with the player name.

When it reaches the client, use this cool thing called SetCore and you can have the client server tell itself to post a message on chat for the player.