How to check if a player has left without using Players.PlayerRemoving?

players.PlayerAdded:Connect(function(plr)
	local LastGrabbed = grabTag:Clone()
	LastGrabbed.Parent = plr
	plr.CharacterAdded:Connect(function(char)
		while true do
			CheckVoid(plr, LastGrabbed.Value)
			wait()
			-- if player has left: break loop
		end
	end)
end)

Is there a way of checking if a player has left without using Players.PlayerRemoving? I’m sorry if this is a dumb question but googling it came up with no results.

2 Likes

There is no other way to detect when a player has left the server.

darn, what do you think I can do then? I can’t leave the while loop to keep looping even after the player has left cause I’m pretty sure that can cause lag.

Instead of using
while true do
use
while Players:FindFirstChild(Player.Name) do

3 Likes

Check the Player’s parent, if it’s nil, then it’s not in the game anymore.

2 Likes

It’s better to tell us your problem. Not how you’re trying to achieve it and come up with solution. Tell us your problem and we might find alternatives.

I actually asked the wrong question and needed to check if the player’s character had been removed. I will next time I make a post, though.

In that case there’s CharacterRemoving event you can use.

then what is about if players have the same name? You better checking user id (which wont be very good) or instead of while true do just use smth like

repeat 
--code
until Player.Parent == nil

pretty sure that will work as well and will accountant for the problems with same names of playars