Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I need help with my equipping animation. Help?

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)

2 comments

1

can't help don't see any code.. perhaps your code block is nil

0

lol

1 answer

✓ Accepted answer
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.

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.