Player.CharacterAdded:Wait() no longer works

Quite simply, I just have a plain
Player.CharacterAdded:Wait()
in a script. This is what it yields in the output.

After this, the rest of the script refuses to run.

Can this be fixed?

Your Player variable is nil. I assume you used Players.LocalPlayer on a server script, which doesn’t work. Although you can get the tool player reference relative to the script from this path:

--Script --> Handle --> Can --> Backpack --> Player
local Player = script.Parent.Parent.Parent.Parent
1 Like

Jut use

local character = Player.Character or Player.CharacterAdded:Wait()

instead of

local character = Player.CharacterAdded:Wait()
1 Like

I already tried this before posting the topic, still thinks I’m indexing nil

Try printing player name player:GetFullName() and see if player actually exists i agree with @KristinaMoment

2 Likes

script:FindFirstAncestorOfClass("Player")

1 Like

Can you share the entire script? We can’t really fix your code without it.

If the character dies or respawns this happens. Instead use:

player.CharacterAdded:Connect(function(character)

end)

or put it under StarterCharacter.

It’s the same thing as player.CharacterAdded:Wait() instead it doesn’t yield

:slightly_smiling_face: :point_up:

Post your actual script if you want more help beyond that.

1 Like

Ight, check this for errors whilst I test out some of the methods listed above

:slightly_smiling_face: :point_up:

Line 3

Change the script to a LocalScript

2 Likes

UPDATE

I’ve changed it to a localscript as one of you have said that it will not work in a server script. The error fixes itself, but it now says Infinite yield possible with Character:WaitForChild("Animator")

note: yes I’m novice at scripting, don’t mind me making dumb errors

Animator would be a child of Humanoid, not Character

1 Like

It works now, but no animation plays. However, I did add a massive amount of numbered print statements which did print. I’ll definitely check the animation before anything though, but this did fix the scripting side of the issue. Thanks!