How to make a condition detect if player character exists?

Well, I’m a bit confused when making a condition that detects that the player’s character exists, since a loop needs the character to exist at all times and I want to add a function to it so that it no longer gives an error. I don’t know whether to use if workspace:FindFirstchild(player.Name) then or if player.Character ~= nil then

1 Like

you could try something like this:

function CheckCharacter(player)
	if (player.Character) then
		return true
	else
		return false
	end
end
1 Like

If you only want to check if it exists, you’ll need to check if PlayerInstance.Character exists.

if (Player.Character)
then
   -- Character exists!
end

If you want to wait for the character to be added (if it doesn’t exist yet), you could do an inline expression:

local Character = Player.Character or Player.CharacterAdded:Wait()
2 Likes