WaitForChild not working?

I have a super simple script, its for some reason not working. can anyone help?

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	if workspace:WaitForChild(Player) then
		print("works, Player Character is found")
	end
end)

the entire point of this is to find the characters scripts through a script, it does not work though. anyone know why?

1 Like

Why would you not just use Player.CharacterAdded?

1 Like

You can’t use WaitForChild in an if statement like that. Use FindFirstChild instead. And I would use CharacterAdded instead as well.

1 Like

Use that

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(character)
print("works, Player Character is found")
end)
end)

btw if you’re wondering why that was happening its because u had to do Player.Name

1 Like
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char)
        -- char will be the player's character
	end)
end)

guy above me posted already oops

1 Like

this is not the full script, I will provide it if you want, but I have narrowed the error down to that point, if I remove the WaitForChild in the real script it works.

nvm it works, sorry for wasting your guys time.

for some reason CharacterAdded did not work, I tried FindFirstChild and that worked though. thanks!

The PlayerAdded event will return the player instance that joined the game, not their character.