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

How to put animation to your tool based on Equipped/Unequipped or Activated/Deactivated?

Here is what I did but it failed to work. (I'm very new to scripting, I'm sorry.)

local Tool = Script.Tool
local canDamage = true

Tool.Equipped:Connect(function()
	local Wield = Tool.Parent.Humanoid:LoadAnimation(script.WieldAnimation)
	local Lunge = Tool.Parent.Humanoid:LoadAnimation(script.LungeAnimation)
	local Slash = Tool.Parent.Humanoid:LoadAnimation(script.SlashAnimation)

	Wield:Play()
end)

Tool.Activated:Connect(function()
	local Wield = Tool.Parent.Humanoid:LoadAnimation(script.WieldAnimation)
	local Lunge = Tool.Parent.Humanoid:LoadAnimation(script.LungeAnimation)
	local Slash = Tool.Parent.Humanoid:LoadAnimation(script.SlashAnimation)

	Wield:Stop()
	Lunge:Play()
end)

Tool.Deactivated:Connect(function()
	local Wield = Tool.Parent.Humanoid:LoadAnimation(script.WieldAnimation)
	local Lunge = Tool.Parent.Humanoid:LoadAnimation(script.LungeAnimation)
	local Slash = Tool.Parent.Humanoid:LoadAnimation(script.SlashAnimation)

	Lunge:Stop()
	Slash:Play()
end)

2 comments

0

whats the error that it gives

0

non of the animations run

1 answer

Basically, you forgot to play it.

Read how the humanoid load animation, which provides more detail than what I'm going to explain.

--Humanoid
local Humanoid = -- Your humanoid here
local Anim = -- Animation "Object"
local animTrack = Humanoid:LoadAnimation(Anim)--[[
 The humanoid "LOADS" the animation and return an "Animation Track"--]]
animTrack:Play()--You forgot to play it.

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