简体   繁体   English

尝试用类人机器人索引 nil

[英]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".我尝试对加入游戏的玩家应用人形描述,但 output 给出错误:“尝试使用人形索引 nil”。 Heres is the code.这是代码。

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

You should wait for the Character to load in the game.您应该等待角色加载到游戏中。 Before applying the HumanoidDescription.在应用 HumanoidDescription 之前。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM