Hey there! I have a perfectly working and more complicated join script that sends a message when the player enters, but I cannot get it to work when I simplify it and try to rewrite it to send a message when the player leaves! This is the script I have for when the player leaves the game (in StarterGui) :
textColor = BrickColor.new("Br. yellowish orange")
game.ReplicatedStorage.PlayerLeftMessage.OnClientEvent:Connect(function(player)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = player.Name..' has disappeared';
Font = Enum.Font.SourceSansBold;
Color = textColor.Color;
FontSize = Enum.FontSize.Size24;
})
end)
It connects to a event in ReplicatedStorage that should be detected by the player leaving. I'm not quite exactly sure what's wrong as I can't get it to work. Meanwhile I got my player join message to work. Player join message is here below incase it is affecting this new script
Player join message's StarterPlayerScripts script :
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('RemoteEventJoin')
textColor = BrickColor.new('Cyan')
local function welcome(playerName)
game.StarterGui:SetCore('ChatMakeSystemMessage', {
Text = playerName..' has joined';
Font = Enum.Font.SourceSansBold;
Color = textColor.Color;
FontSize = Enum.FontSize.Size24;
})
end
remoteEvent.OnClientEvent:Connect(welcome)
And here is the accompanying script in ServerScriptService for the join message as well :
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('RemoteEventJoin')
local function onPlayerJoin(player)
remoteEvent:FireAllClients(player.Name)
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
I'm unsure how to rewrite the "join message" script to work for leaving players, which is why the "leaving players" script is less intact than the join players script. Thank you to anyone who reads!

1 comment
This helped perfectly, thank you! I wasn't sure how to get the event to fire properly with OnClientEvent, thank you for this! Also yes, the "PlayerLeftMessage" was a remoteevent in ReplicatedStorage. Thank you very much!