So, I made a code where if you joined message pop-up in chat that worked Ok, But how about the left message. I tried multiple times and it didn't work what's wrong with it?
This script in ServerScriptService
local MessageEvent = game.ReplicatedStorage.PlayerLeftMessageEvent game.Players.PlayerRemoving:Connect(function(Player) repeat wait() until Player.Character or Player.CharacterRemoving:Wait() local text = "{System} "..Player.Name..", Has left to the game" local color = Color3.fromRGB(255,0,0) local font = Enum.Font.Cartoon MessageEvent:FireAllClients(text,color,font) end)
What wrong with that's it's not working??
This for StarterGUI
local StarterGui = game:GetService("StarterGui") local MessageEvent = game.ReplicatedStorage.PlayerLeftMessageEvent MessageEvent.OnClientEvent:Connect(function(text,color,font) StarterGui:SetCore("ChatMakeSystemMessage",{ Text = text, Color = color, Font = font }) end)
You can delete the server script and the event, this is a 100% client script
local SG = game:GetService("StarterGui") local Players = game:GetService("Players") Players.PlayerRemoving:Connect(function(Player) SG:SetCore("ChatMakeSystemMessage", { Text = "{System} "..Player.Name.." has left the game", Color = Color3.fromRGB(255,0,0), Font = Enum.Font.Cartoon }) end)
This detects the player removing on the client. Keep in mind this won't work if a player gets disconnected from the game.
On line 4, you put:
repeat wait() until Player.Character or Player.CharacterRemoving:Wait()
Your script is probably waiting infinitely here, hence why any of the code isn't running.
You don't really have to put this line into your code, as once the player removes they're essentially already removed from the game. There is no point in calling the character after.