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

How do I loop this animation without anything interrupting it?

Asked by
xEiffel 280 Moderation Voter
6 years ago
Edited 6 years ago

Hi and thanks for reading my question, I've been wondering for days on how to make a looping animation that never stops, when I try to do this, It cancels when it fires another animation, and I don't know how to stop it, basically I'm starting off a function where it fires if you have been dealt a certain amount of damage(haven't added that in yet) but what I have so far is clicking on a button, however, when you click on that button the animation plays, but jumping or stop walking just cancels the animation, here's what I have so far.

    local a = Instance.new('Animation')
    a.AnimationId = 'rbxassetid://1171537883'
    local player = game.Players.LocalPlayer
    workspace:WaitForChild(player.Name,3)
    local trackanimation = nil
    local playstance = true
    function playAnimation(AnimationSource)
        if playstance == true then 
            trackanimation = workspace[player.Name].Humanoid:LoadAnimation(a)
                while wait() do
            trackanimation:Play()
            end
        end
    end
script.Parent.MouseButton1Click:connect(playAnimation)

help is extremely appreciated! Thanks.

1 answer

Log in to vote
0
Answered by 6 years ago

Try to use pcall, it should help

Here’s what the code should look like

local a = Instance.new('Animation')
a.AnimationId = 'rbxassetid://1171537883'
local player = game.Players.LocalPlayer
workspace:WaitForChild(player.Name,3)
local trackanimation = nil
local playstance = true

function playAnim(source)
pcall(function()
if playstance == true then
trackanimation = workspace[player.Name].Humanoid:LoadAnimation(a)
while wait() do
trackanimation:Play()
end
end
end
end

If that doesn’t work try storing the animation code in a empty script that has no other code in it.

0
Just forgot to add this code at the end: script.Parent.MouseButton1Click:connect(playAnimation) OMG_Gaming404 73 — 6y
0
Sorry, it doesn't work OMG_Gaming404 73 — 5y
Ad

Answer this question