I have assigned a specific player in my game to ‘player1’ and I was wondering if there was a way to detect if that player leaves the game. Because Players.PlayerRemoving seems to just detect when any player leaves. Thanks
depends when you need to start detect:
essentially you will want to use player.PlayerRemoving
need more context though… why do you want a specific player
PlayerRemoving event returns the player that is removing as a param.
So you could have a simple if statement that checks if that player equals your “specific player”. Whether that is directly with a reference or something like userid.
Pretty simple:
game.Players.PlayerRemoving:Connect(function(player)
if player.Name(Or .UserId.) == ---(Whatever you want to put here e.g Username, UserId, etc.). then
---(Your code here)
end
end)
Wrote this on my phone so it might not be correct.
You would want to do player.Name
/ player.UserId
, comparing a userdata to a string/number won’t work.
game.Players.PlayerRemoving:Connect(function(player)
if player.Name == "name_here" then
-- do stuff
end
end)
put the “name_here” as the player’s name
you can also change the if statement to “if player.UserId == id here” btw. Remember to put the “id here” as the player’s id.
Yeah, I was going to do that but didn’t. Sorry
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.