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

01local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Anim)
02local animPause = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.AnimPause)
03 
04 
05script.Parent.Equipped:Connect(function(mouse)
06    mouse.Button1Down:Connect(function()
07        anim:Play()
08        wait(anim.Length)
09        anim:Stop()
10        animPause:Play()
11    end)
12end)
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:

01local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Anim)
02local animPause = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.AnimPause)
03local animResumeAnim = Instance.new("Animation")
04animResumeAnim.Parent = script
05animResumeAnim.Name = "AnimResume"
06local animResume = game.Players.LocalPlayer.Humanoid:LoadAnimation(animResumeAnim)
07 
08script.Parent.Equipped:Connect(function(mouse)
09    mouse.Button1Down:Connect(function()
10        anim:Play()
11        wait(anim.Length)
12        anim:Stop()
13    anim:Destroy()
14        animPause:Play()
15    end)
16    mouse.Button1Up:Connect(function()
17    animResume:Play()
18    end)
19end)

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