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 8 years ago
Edited 8 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.

01local Players = game:GetService('Players')
02 
03function onPlayerRemoved(player)
04    game:GetService('StarterGui'):SetCore('ChatMakeSystemMessage',{
05    Text = ('Server| '.. player.Name .. ' has left the game.');
06    Color = Color3.new(.9,.5,.05);
07    Font = Enum.Font.SourceSansBold;
08    FontSize = Enum.FontSize.Size18;
09    })
10end
11 
12Players.PlayerRemoving:connect(onPlayerRemoved)
13 
14for _,player in pairs(Players:GetPlayers()) do
15     onPlayerRemoved(player)
16end
0
If I helped, don't forget to accept my answer please. User#11440 120 — 8y

1 answer

Log in to vote
2
Answered by 8 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,

01local Players = game:GetService('Players')
02 
03function onPlayerRemoved(player)
04    game:GetService('StarterGui'):SetCore('ChatMakeSystemMessage',{
05    Text = ('Server| '.. player.Name .. ' has left the game.');
06    Color = Color3.new(.9,.5,.05);
07    Font = Enum.Font.SourceSansBold;
08    FontSize = Enum.FontSize.Size18;
09    })
10end
11 
12Players.PlayerRemoving:connect(onPlayerRemoved)

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

Good Luck!

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

Answer this question