Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Not showing "Player has left the server." when someone leaves?

****I was working on a script to when a player leaves the server it will say the player has left server on the chat. But as soon as I join the server, it says that.

local Players = game:GetService('Players')

function onPlayerRemoved(player)
	game:GetService('StarterGui'):SetCore('ChatMakeSystemMessage',{
	Text = ('Server| '.. player.Name .. ' has left the game.');
	Color = Color3.new(.9,.5,.05);
	Font = Enum.Font.SourceSansBold;
	FontSize = Enum.FontSize.Size18;
	})
end

Players.PlayerRemoving:connect(onPlayerRemoved)

for _,player in pairs(Players:GetPlayers()) do
     onPlayerRemoved(player)
end


1 comment

0

If I helped, don't forget to accept my answer please.

1 answer

✓ Accepted answer

It's because you have useless code.

Lines 14-16 do nothing but call the function as soon as the script runs.

Fix,

Remove the extra lines of code,

local Players = game:GetService('Players')

function onPlayerRemoved(player)
    game:GetService('StarterGui'):SetCore('ChatMakeSystemMessage',{
    Text = ('Server| '.. player.Name .. ' has left the game.');
    Color = Color3.new(.9,.5,.05);
    Font = Enum.Font.SourceSansBold;
    FontSize = Enum.FontSize.Size18;
    })
end

Players.PlayerRemoving:connect(onPlayerRemoved)

Sometimes thing are simple, and that should be the right answer.

Good Luck!

2 comments

0

Thanks bro!

0

:P

This discussion is preserved as it was. New answers, comments, and votes are closed.