Attempt to index nil with character

I’m trying to make the game detect if the 2 players competing are still in-game after each other’s turns. Me and my alt are both still in-game, but the script stops working at this part, changes the text to “Moving on…” and gives me the error “attempt to index nil with character”???

	if not player1 or not player1:FindFirstChild("Character") then
		
		if player2 and player2:FindFirstChild("Character") then
			player2.Character:MoveTo(lobbyTeleport.Position)
			screenText = "Moving on..."
			wait(.1)
			Remote:FireAllClients(screenText)
			wait(2)
			startRound()
		elseif player1 and player1:FindFirstChild("Character") then
			player1.Character:MoveTo(lobbyTeleport.Position)
			screenText = "Moving on..."
			wait(.1)
			Remote:FireAllClients(screenText)
			wait(2)
			startRound()
		else 
			screenText = "Moving on..."
			wait(.1)
			Remote:FireAllClients(screenText)
			wait(2)
			startRound()
		end
		return
	end
1 Like

character is a property of a player not a descendant. just do

if player1 and player1.Character then

and do the same for player2

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.