Help with Animation script?

Hello, my name is Kyle. I don’t know what I am doing wrong for this one animation script. It’s an old one, but whenever I look it up it’s the same thing, and it doesn’t work. It has no errors though. It’s about when you equip a tool it will play an animation, and the other one is when you glitch with a tool, it will play a different animation. Here is what I do. (It’s me just talking to myself. But it might also be an animation problem?) (Oh and I made the animation)

–Make a tool, then make a script and put this.

local sp = script.Parent.Speed
local tool = script.Parent
local animation = tool:WaitForChild(“Animation”)

function onEquip(mouse)
local char = tool.Parent
local hum = char:FindFirstChild(“Humanoid”)

if char and hum then
local animationTrack = hum:LoadAnimation(animation)
animationTrack:Play()
animationTrack:AdjustSpeed(sp.Value)
wait(2.5)
script.Parent:Remove()
end

end

–Then add a number value to the tool rename to speed
–Insert animation to tool, and paste your animation
–And done

--Make a tool, then make a script and put this.

local sp = script.Parent.Speed
local tool = script.Parent
local animation = tool:WaitForChild("Animation")

local function onEquip()
    local char = tool.Parent
    local hum = char:FindFirstChild("Humanoid")

    if char and hum then
        local animationTrack = hum:LoadAnimation(animation)
        animationTrack:Play()
        animationTrack:AdjustSpeed(sp.Value)
        wait(2.5)
        script.Parent:Remove()
    end
end

tool.Equipped:Connect(onEquip)

I think the you forgot to connect the function? :thinking:

1 Like