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

How to pause an animation when it ends?

Asked by 4 years ago

I did this but the transition is not so smooth. Is there any way to make a simpler and better script like this? Please help, thank you! <3

local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Anim)
local animPause = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.AnimPause)


script.Parent.Equipped:Connect(function(mouse)
    mouse.Button1Down:Connect(function()
        anim:Play()
        wait(anim.Length)
        anim:Stop()
        animPause:Play()
    end)
end)
0
I haven't tried this myself, but I got curious and looked up what I think you're asking. The main thing I found was that you can set the animation speed to 0 and it'll essentially pause it wherever in the animation it is. This is the website I found that mentions this: https://devforum.roblox.com/t/pausing-animations/288995 Knineteen19 307 — 4y
0
but how if i want to continue it after mouse.button1up Inciney 7 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I think you would need to make a continuing animation after that. You also need to destroy the playing animation when stopping. Code:

local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Anim)
local animPause = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.AnimPause)
local animResumeAnim = Instance.new("Animation")
animResumeAnim.Parent = script
animResumeAnim.Name = "AnimResume"
local animResume = game.Players.LocalPlayer.Humanoid:LoadAnimation(animResumeAnim)

script.Parent.Equipped:Connect(function(mouse)
    mouse.Button1Down:Connect(function()
        anim:Play()
        wait(anim.Length)
        anim:Stop()
    anim:Destroy()
        animPause:Play()
    end)
    mouse.Button1Up:Connect(function()
    animResume:Play()
    end)
end)

If this works, please accept. Otherwise, comment and I will edit my answer.

Happy to help, b_mni.

0
is it possible to do this with only 1 animation? i just think it would turn out smoother. Inciney 7 — 4y
Ad

Answer this question