How To Only Teleport While Player Is Alive & In Game?

So I have a round system for a minigame after doing all the things like choosing map etc, it comes to teleporting the player.

I need this player to only teleport while they are alive and in game to prevent the Server script from thinking that the player is in round which causes the minigame to break.

Somehow you are able to by pass the if statement (if Character.Humanoid.Health > 0 then) if you reset as soon as the server is going to teleport the player.

What is the best approach for this?

So far I have a if statement that checks if the player is alive and a “PlayerRemoving” Event but I’m not sure if its guranteed to work.

I have been thinking of preventing the player from being able to reset when teleporting but I’m not sure if that is smart or not.

Please do ask if you need more details.

Portion Of The Script:

		for _, Player in Players:GetPlayers() do
			--- Player
			local Character = Player.Character
			local Boolean = Player.PlayerGui.Boolean
			
			--- Disable Values
			Boolean.CanClimb.Value = false -- Disables CanClimb Which Also Disables Active Arms So Player Does No Glitch Upon Teleport If Grabbing
			Boolean.CanMove.Value = false -- Prevents Player Moving, Gets Enabled Later
			Player.Neutral = false -- Disables Neutral As Indication That The Player Is In Round
			
			--- Teleport Pcall
			local SuccessTeleport, Error = pcall(function()
				if Character.Humanoid.Health > 0 then -- If Player Not Dead, Bug ProVision
					local Chosen_Point = Teleport_Points[math.random(1, #Teleport_Points)] -- Choses Random Point
					Player.Character:MoveTo(Chosen_Point.Position) -- Teleport Player
				end
			end)

			if not SuccessTeleport then -- If Failed To Teleport Player
				warn("Failed To Teleport Player: ", Player, " Error: ", Error) -- Warn Report
				
				if Players:FindFirstChild(Player.Name) then -- If Player Still Exists Enable Values Again
					Boolean.CanClimb.Value = true
					Boolean.CanMove.Value = true
					Player.Neutral = true
				end

			else -- If Teleported
				-- Insert Player To Table "Playing"
				table.insert(Playing, {["Player"] = Player}) 
				print("Added ", Playing)
				
				--- Event Connections ---
				Died = Player.Character.Humanoid.Died:Connect(function() -- If Player Died Remove From "Playing" Table
					Handle_Table_Playing(Player, true) -- Removes Player From Table "Playing"
				end)
				
				Left = Players.PlayerRemoving:Connect(function(Player_Left) -- If Player Left Mid Game Then Remove From "Playing" Table
					Handle_Table_Playing(Player_Left, true) -- Removes Player From Table "Playing"
				end)
					
			end
		end

Not quite sure I understand what you’re asking.

Do you want to check if the player’s character is present and that they haven’t left the game?

A few methods you could try to check (in your loop):

if not player:IsA("Player") then continue end
if not player.Character then continue end
if not workspace:FindFirstChild(player.Name) then continue end
if not Players:FindFirstChild(player.Name) then continue end

Hope this helps.

Mb I forgot to put in this part

If you want the player to be able to reset at other points in the game, that might be the best option (if you are only checking for their character). You can use a RemoteEvent to do this.