Trouble with humanoid and LoadAnimation()

I’m trying to load an animation to the humanoid, but the humanoid seems to be nil, here’s the script:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")

local tool = script.Parent
local anim = script.Anim

local debounce = false

local animTrack = hum:LoadAnimation(anim)

And the error is:
attempt to index nil with 'LoadAnimation'

Replace local hum = char:FindFirstChildOfClass("Humanoid") with local hum = char:WaitForChild("Humanoid")

1 Like

it worked thx! One more thing, why doesn’t “tool.Activated” work?

It should work, can you show the code?

I figured it out, it’s because the tool doesn’t have a handle, so I just disabled the “needs a handle” property