takezo
takezo

Reputation: 91

Attempt to index nil with humanoid

I tried to apply a Humanoid Description on a player that joined the game but the output gives an error: "Attempt to index nil with humanoid". Heres is the code.

game.Players.PlayerAdded:Connect(function(Player)
    Player.Character.Humanoid:ApplyDescription(game.ServerStorage.HumanoidDescription)
end)

Upvotes: 0

Views: 263

Answers (1)

Tsering
Tsering

Reputation: 483

You should wait for the Character to load in the game. Before applying the HumanoidDescription.

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(character)
       wait()
       character:WaitForChild("Humanoid"):ApplyDescription(game.ServerStorage.HumanoidDescription)
    end)
end)

Upvotes: 0

Related Questions