Animation Going Back to the Beginning Point [SOLVED]

Hello!

I’ve created an animation alongside with a script; however, while the script itself is fine,
the animation for some strange reason moves back to the beginning point then teleporting to the end point.

I’d love to know if there is a way to fix this issue!

-- Here is the script incase if you need it!

local Prompt = script.Parent.Object.Prompt.ProximityPrompt

local isvaulting = false

local Animation = script.Vaulting

local End_Point = script.Parent.End_Point
local Start_Point = script.Parent.Start_Point

Prompt.Triggered:Connect(function(player)
	
	local Playing = player.Character.Humanoid:LoadAnimation(Animation)
	
	if not isvaulting then
		
		player.Character.Humanoid.WalkSpeed = 0
		
		Playing:Play()
		
		isvaulting = true
		isontheotherside = true
		
	end
	
	Playing.Ended:Connect(function()
		
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.HumanoidRootPart.CFrame = CFrame.new(End_Point.Position)
		
		isvaulting = false
		
	end)

	
end)

robloxapp-20230827-1310343.wmv (872.6 KB)

I believe it’s a common issue with animations, where they go back to the idle animation before finishing. Perhaps you should move the player’s CFrame instead of animating it (so that they go back to the idle animation at where they finish vaulting, rather than where they started vaulting).

1 Like

Do you mean like Tweening it or???

Tweening it would be a solution, yes.

I actually don’t know how to tween things, so if you could give me an example that’d be great. (You can use the script I provided as well.)

It’s pretty easy actually, you can do it on one or two lines, but I have trust issues with the garbage collector (memory leaks are serious), so I’ll need to add in 2 more lines.

local TweenService = game:GetService("TweenService")

local Prompt = script.Parent.Object.Prompt.ProximityPrompt

local isvaulting = false

local Animation = script.Vaulting

local End_Point = script.Parent.End_Point
local Start_Point = script.Parent.Start_Point

Prompt.Triggered:Connect(function(player)
	
	local Playing = player.Character.Humanoid:LoadAnimation(Animation)
	
	
	if not isvaulting then
		
		player.Character.Humanoid.WalkSpeed = 0
		
		-- We put this code here to prevent unnecessary processing power waste
		-- Create info for the tween
		local TI = TweenInfo.new(--[[PUT ANIMATION DURATION HERE]], Enum.EasingStyle.Linear)
		-- Create the tween
		local cframeTween = TweenService:Create(player.Character.HumanoidRootPart,TI,{CFrame = CFrame.new(End_Point.Position)})
		cFrameTween:Play() -- Play the tween

		Playing:Play()
		
		isvaulting = true
		isontheotherside = true
		
	end
	
	Playing.Ended:Connect(function()
		
		player.Character.Humanoid.WalkSpeed = 16
		
		isvaulting = false
		
		cFrameTween:Destroy() -- Destroy the tween (just in case)
	end)

	
end)
1 Like

Try to use Stopped instead Ended. Stopped ignores animation fading unlike Ended.

2 Likes

Alright, I’ll check the example you provided and see if it works.

Oh yeah, I just had a look at the documentation (I’m pretty slow) and Cog is right, you should probably be using Stopped. Not sure if you’ll still see any funky stuff with the animation fade-out though.

Ok, I’ll be doing what @CogTheSuit said as well.

I’ve encountered another problem! I’ll send the video as it is confusing for me to explain it.

EDIT: When I enable the ShiftLockSwitch it plays fine.

robloxapp-20230827-1347228.wmv (903.8 KB)

Maybe temporarily freeze HumanoidRootPart until animation ends?

I’ll try that. 30char30char30char

That did not work. 30char30char

Alright, I think I managed to fix it, thank you @TestyLike3 and @CogTheSuit for your help, I’ll mark @TestyLike3 's solution incase if anyone had the same issues as me.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.