Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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)
0
whats the error that it gives Code1400 75 — 4y
0
non of the animations run Inciney 7 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.
Ad

Answer this question