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

Can someone help with this Animation Tool?

Asked by 9 years ago

So i tried making a tool that cancels the animations currently in the character (idle, fall etc.), insert and play an animation, then resume the default animations and delete the custom animation when the mouse is clicked. Here's the script and I realize it may be a little messy...

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Salute1-item?id=273131510"

local animTrack = nil
local canPlay = true
game.Players.PlayerAdded:connect(function(player)
    while not player.Character do wait() end
    local character = player.Character
    local animateScript = character.Animate

local bin = script.Parent 
bin.Selected:connect(function(Mouse)
    Mouse.Button1Down:connect(function()
        animateScript:Stop()
                if canPlay then
                local player = game.Players.LocalPlayer.Character
                canPlay = false
                animTrack = player.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid
                animTrack:Play() -- Start the animation
                animTrack.KeyframeReached:connect(function(keyframeName) -- Bind function to KeyframeReached event
                if keyframeName == "SaluteEnd" then
                canPlay = true
                animation:Destroy()
                animateScript:Play()
                end
            end)    
        end
    end)
end)
end)
wait()

If someone could help that would be great.

Answer this question