Having a problem when trying to add a default idle animation for my starter player using the script.
The error message is this: Players.abelgetachew19.PlayerScripts.AnimationHandles:4: attempt to index nil with 'Humanoid' - Client - Animation Handles:4
local FloatingIdle = script.Floating local player = game.Players.LocalPlayer local char = player.Character local hum = char.Humanoid local FloatingAnimation = hum:LoadAnimation(FloatingIdle) game.Players.PlayerAdded:Connect(function(startanimation) if startanimation == true then FloatingAnimation:Play() end end)
Add a :WaitForChild()
to the variable hum
local FloatingIdle = script.Floating local player = game.Players.LocalPlayer local char = player.Character local hum = char:WaitForChild("Humanoid") local FloatingAnimation = hum:LoadAnimation(FloatingIdle) game.Players.PlayerAdded:Connect(function(startanimation) if startanimation == true then FloatingAnimation:Play() end end)