Script cannot detect character

Video with the problem

btw I’ve tried using both Players:GetPlayers and Players:GetChildren but they both cause infinite yield

Use player.Character or player.CharacterAdded:Wait() instead of the WaitForChild method as the Character isn’t a child of the player.

2 Likes

character isnt a child of player, you cant use player:WaitForChild(“Character”)
you can define character with

local character = player.Character
if character then
 -- code
end

or if you want to yield until the character exists

local character = player.Character or player.CharacterAdded:Wait()
-- code

in your case i think its better not to yield.

2 Likes

oh mb I forgot I should’ve known that character is an objectvalue

1 Like

this helped but the second reply did more