I want to have the game do something when the player leaves the game. I've done some research and found PlayerRemoved, but I've never used the function before, and when I attemped to use it, nothing really happened at all when a player left. Could someone please help me out?
local event = game:GetService("ReplicatedStorage").terminalOff
game.GetService("Players").PlayerRemoving:Connect(function(player)
event:FireServer(game:GetService("Players").LocalPlayer)
end)
The code is in a local script.
When a player leaves the game, an event will be fired to the Server, which will tell the server to re-enable a click detector I have in my game.

2 comments
When a player leaves the game, enable the click detector from the server; everything on the server side. Not a local script. I can see this working well, unless the click detector is required to be on a local script. But then what would be the reason for it? Do you have some more info you could provide on this?
Thank you, I moved my code into a server script, as a child to the part the ClickDetector was in, and it worked just as I wanted it to in the first place.