Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
Edited 7 years ago

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


0
If I helped, don't forget to accept my answer please. User#11440 120 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago

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!

0
Thanks bro! FearlessAfrican 34 — 7y
0
:P User#5423 17 — 7y
Ad

Answer this question