Pausing animation after reaching a particular keyframe

Hello! I want the animation to pause right at the end of the animation. I have already added an event in a keyframe for it. However, I can’t seem to make it pause when it reached that keyframe. Is there anyway to do so? Here is my script and what happens when the animation plays.

Script

local userinputservice = game:GetService("UserInputService")
local textchatservice = game:GetService("TextChatService")
local chatinputbarconfiguration = textchatservice:FindFirstChildOfClass("ChatInputBarConfiguration")
local Tweenservice = game:GetService("TweenService")
userinputservice.InputBegan:Connect(function(button)
	local inchat = chatinputbarconfiguration.IsFocused
	if button.KeyCode == Enum.KeyCode.Space and inchat == false then
		local timestart = tick()
		local tweenInfo = TweenInfo.new(4) -- set to the duration you want
		script:SetAttribute("Time",timestart)
		local tweenGoal = {Size = UDim2.new(1,0, -1, 0)} -- replace with the actual values of your UI, it can be different for you.
		tweenstart = Tweenservice:Create(script.Parent, tweenInfo, tweenGoal) -- make the tween and play it
		tweenstart:Play()
		local player = game.Players.LocalPlayer
		local character = player.Character
		local humanoid = character:WaitForChild("Humanoid")
		local bodyposition = Instance.new("AlignPosition")
		bodyposition.Parent = humanoid
		humanoid.JumpHeight = 0
		humanoid.WalkSpeed = 0
		humanoid.AutoRotate = false
		local hrp = character:WaitForChild("HumanoidRootPart")
		hrp.Anchored = true
		local track = humanoid:LoadAnimation(script.Animation)
		local tweeninfoforheight = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
		local goal = {CFrame = hrp.CFrame * CFrame.new(Vector3.new(0,2,0))}
		local tweenforheight = Tweenservice:Create(hrp,tweeninfoforheight,goal)
		tweenforheight:Play()
		track:Play()
		track:GetMarkerReachedSignal("Pose"):Connect(function()
			track:Stop()
		end)
	end
end)

Result

Replying to this topic to bump it up

Try setting animation track speed to 0 and back to normal when needed.

image

Thank you! It works now! :heart::heart::heart: