Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to pause an animation when it ends?

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)

2 comments

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

0

but how if i want to continue it after mouse.button1up

1 answer

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.

1 comment

0

is it possible to do this with only 1 animation? i just think it would turn out smoother.

This discussion is preserved as it was. New answers, comments, and votes are closed.