So I tried to play an equipping animation on my sword when I equip it. I did this through a local script. However, when I equip the sword, only the default equip animation is played. Please help me.
Here is my script:
local sword = script.Parent local humanoid = sword:FindFirstChild("Humanoid")
sword.Equipped:connect(function() if humanoid then local anim = sword:FindFirstChild("EquipAnim") if anim then local loadedAnim = humanoid:LoadAnimation(anim) if loadedAnim then loadedAnim:Play() end end end end)
local sword = script.Parent local humanoid = game:GetService("Players").LocalPlayer.Character:FindFirstChild("Humanoid") sword.Equipped:Connect(function() if humanoid then local anim = sword:FindFirstChild("EquipAnim") if anim then local loadedAnim = humanoid:LoadAnimation(anim) if loadedAnim then loadedAnim:Play() end end end end)
The problem was your local humanoid = sword:FindFirstChild("Humanoid")
part,
there is no humanoid in your sword tool, which is what you're searching for when you do "sword:FindFirstChild()"
Also if you aren't already, you should run this on a LocalScript, instead of a Server Script.