Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Way to locally tell when you're leaving the game?

I know Players.PlayerRemoving works locally now but it doesnt work if you're the one leaving the game. Is there a way to tell if you're leaving the game(from a local script)?

1 answer

The same way. The way to check if the player who is leaving is you, is to set an if statement. Example,

--In local script
game.Players.PlayerLeaving:connect(function(plr)--plr mean the player that left.
    if plr.Name == "Player1" or plr.Name == "Causticity" then---checks if plr name is Player1 or yours
        ---do stuff here
    end
end

However if you wanted to do stuff like change the game then you would have to set up RemoteEvents to connect the server.

That is the answer. Good Luck!

This discussion is preserved as it was. New answers, comments, and votes are closed.