I'm trying to animate a tool in my player's starterpack, but for some reason I keep getting an error message that says "attempt to index field 'Character' (a nil value)" referring to line 3. I've tried several variations where I make the script wait for everything to load, but none of those worked either.
This is the code:
tool = script.Parent
local animation = tool.SwingAnimation
humanoid = game.Players.LocalPlayer.Character.Humanoid
local track = humanoid:LoadAnimation(animation) --loads the animation into humanoid
tool.Activated:Connect(function()
track:Play()
wait(1)
end)
tool.Deactivated:Connect(function()
track:Stop()
end)
What am I doing wrong? Thanks!

2 comments
Thank you!
wht this is not how you wait for the players character. Use events not loops. -1