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

Help with animations?

Asked by 9 years ago
local tool = script.Parent
local animation = tool:WaitForChild("Animation")
local animation2 =tool:WaitForChild("Animation2")
local player = game.Players.LocalPlayer

local animationtrack
local buttonpressed = false

tool.Equipped:connect(function()
    local character = player.Character
    local humanoid = character:WaitForChild("Humanoid")
    animationtrack = humanoid:LoadAnimation(animation)
    animationtrack:Play()
end)




    tool.Activated:connect(function()
        if not buttonpressed then
        buttonpressed = true
        local character = player.Character
        local humanoid = character:WaitForChild("Humanoid")
        animationtrack = humanoid:LoadAnimation(animation2)
        animationtrack:Play()
        wait(3)
        buttonpressed = false
        end
    end)



tool.Unequipped:connect(function()
    animationtrack:Stop()
end)

There are a few problems going on here... 1. If I try to unequip the tool while the animation is playing the character doesn't go back into its default position. The character stays in the position of the first animation 2. If I try to unequip the tool after I play the animation once or more, when I unequip the tool, the character again stays in the position of the first animation. :P Please help!

2 answers

Log in to vote
0
Answered by 9 years ago

The method Stop of the AnimationTrack will make the animation end when you call it. When your tool is unequipped, call this function to end your animation prematurely.

0
I already have stop in my script though... help! swimmaster07 25 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Thx but I don't completely understand what you're saying. Do you think you could modify my script and show me what you mean?

Answer this question