****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
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!