How to have the ability to pause/unpause tasks?

I basically have a sequence, that plays, but if I wanted to add a pause button, that pauses the sequence at any time and when unpaused, resumed the sequence, how would that be done?

I was thinking of maybe using a coroutine, but is there any other way this can be done, as that would not be an instantaneous stop.

Can you clarify what the script does and how it is made? Perhaps a snippet? It’s too little information to know what exactly you are trying to achieve.

What I am trying to achieve is in the post, the ability to play/pause a sequence at any time.

Here is a small snippet of the sequence:

graduate.Humanoid:MoveTo(GraduationResources.GraduatePath["1"].Position)
        graduate.Humanoid.MoveToFinished:Wait()

        graduate.Humanoid:MoveTo(GraduationResources.GraduatePath["2"].Position)
        graduate.Humanoid.MoveToFinished:Wait()
        animationTrack:Stop()

        AnimNation.tween(graduate.PrimaryPart,
            {t = 0.7, s = Enum.EasingStyle.Cubic, d = Enum.EasingDirection.Out},
            {CFrame = CFrame.lookAt(graduate.PrimaryPart.Position, GraduationResources.LookToPoint.Position)}
        )

        task.wait(1)

        local container = DialogPane.new(graduate.Name)
        container.Gui.Parent = self._screenGui
        container:Show()
        container:SetText("I'm so happy to be here! 🎉")
        container.Completed:Wait()

        for _, particleEmitter in pairs(confetti:GetDescendants()) do
            if particleEmitter:IsA("ParticleEmitter") then
                local emitCount = if particleEmitter:GetAttribute("EmitCount") then math.floor(particleEmitter:GetAttribute("EmitCount") * 0.5) else nil
                particleEmitter:Emit(emitCount)
            end
        end

        celebrationAnimationTrack:Play()

What does the code do and how is the pause behavior supposed to be like?

If I was you I would start with a variable such as isPlaying and then set it to false when I want to pause but I’m not sure how you could handle pausing and unpaying your current script.