✓ Accepted answer
When the script first runs, the parent of the tool will be Backpack. This means that there won't be a Humanoid in it. You really have two options to fix this:
Wait until the tool is equipped to do the actions of line 2 and 3. This will mean that now the tool's parent is your Character, so there will be a Humanoid in it.
function onEquipped()
local hum = tool.Parent:WaitForChild("Humanoid")
anim = hum:LoadAnimation(tool.Animation)
anim:Play()
end
The second option is to use the LocalPlayer and get the Humanoid from there.
local tool = script.Parent
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local chr = plr.Character
local hum = chr:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(tool.Animation)
1 comment
Thanks so much!