How can I smoothly switch between animations and resume them?

Hi, I’m looking at how I could make the animations change smoothly and resume when I play them again

I’m looking for the smoothness between animations to be like this, but it only works with the animation of walking backwards

because when I try to make the smooth change between animations with the animation of walking forward this happens:

because also when the animation is in the process of stopping and I press a key again the animations start from 0:


and in this one I need it to resume, not start again

my code here:

local animationSpeed = Instance.new("NumberValue")
	animationSpeed.Value = 0

self.DirectionsConnection = RunService.RenderStepped:Connect(function()
			local x,y,z = self.Camera.CFrame:ToOrientation()
			cframe = CFrame.new(self.RootPart.Position) * CFrame.Angles(0,y,0)
			

			local magnitud = math.clamp(math.round((self.RootPart.AssemblyLinearVelocity*Vector3.new(1,0,1)).Magnitude), 0, 10)
			
			TweenService:Create(animationSpeed, TweenInfo.new(1),{Value = magnitud/10}):Play()
			--print(animationSpeed.Value)
			
			if not self.WalkBackwardAnimation.IsPlaying then
				if self.WalkForwardAnimation ~= nil then
					if self.WalkForwardAnimation.IsPlaying then
						self.WalkForwardAnimation:AdjustSpeed(animationSpeed.Value)
					end
				end
			end

			if not self.WalkForwardAnimation.IsPlaying then
				if self.WalkBackwardAnimation ~= nil then
					if self.WalkBackwardAnimation.IsPlaying then
						self.WalkBackwardAnimation:AdjustSpeed(animationSpeed.Value)
					end
				end
			end
			
			--// MAGNITUDE
			local MoveDirection = cframe:VectorToObjectSpace(self.Humanoid.MoveDirection)
			local RoundDirection = Vector3.new(math.round(MoveDirection.X),math.round(MoveDirection.Y),math.round(MoveDirection.Z))
			local MGTUDE = math.round((self.RootPart.AssemblyLinearVelocity*Vector3.new(1,0,1)).Magnitude)
			
			if self.ShiftLockActive == true then
				if MGTUDE > 0 then
					
					--//ROTATION DIRECTION
					--// FORWARD | BACKWARD //--------------
					if RoundDirection == Vector3.new(0,0,-1) then
						if DirectionHandler ~= "Forward" then
							DirectionHandler = "Forward"
							spawn(function() Straight() end)
						end
					elseif RoundDirection == Vector3.new(0,0,1) then
						if DirectionHandler ~= "Backward" then
							DirectionHandler = "Backward"
							spawn(function() Straight() end)
						end
					end
					
					--// LEFT | RIGHT //--------------
					if RoundDirection == Vector3.new(-1,0,0) then
						if DirectionHandler ~= "Left" then
							DirectionHandler = "Left"
							spawn(function() Left() end)
						end
					elseif RoundDirection == Vector3.new(1,0,0) then
						if DirectionHandler ~= "Right" then
							DirectionHandler = "Right"
							spawn(function() Right() end)
						end
					end
					
					--// DIAGONAL FORWARD //--------------
					if RoundDirection == Vector3.new(-1,0,-1) then
						if DirectionHandler ~= "Left" then
							DirectionHandler = "Left"
							spawn(function() Left() end)
						end
					elseif RoundDirection == Vector3.new(1,0,-1) then
						if DirectionHandler ~= "Right" then
							DirectionHandler = "Right"
							spawn(function() Right() end)
						end
					end
					
					--// DIAGONAL BACKWARD //--------------
					if RoundDirection == Vector3.new(-1,0,1) then
						if DirectionHandler ~= "Right" then
							DirectionHandler = "Right"
							spawn(function() Right() end)
						end
					elseif RoundDirection == Vector3.new(1,0,1) then
						if DirectionHandler ~= "Left" then
							DirectionHandler = "Left"
							spawn(function() Left() end)
						end
					end
					
					--//ANIMATION EASING
					if RoundDirection == Vector3.new(0,0,1) or RoundDirection == Vector3.new(-1,0,1) or RoundDirection == Vector3.new(1,0,1) then --// BACKWARD
						BackwardActive = true
						if self.Running == false then
							if not self.WalkBackwardAnimation.IsPlaying then
								self.WalkBackwardAnimation:Play(.5)
							end
							if self.WalkForwardAnimation.IsPlaying then
								self.WalkForwardAnimation:Stop(.5)
							end
						end


					elseif RoundDirection ~= Vector3.new(0,0,1) or RoundDirection ~= Vector3.new(-1,0,1) or RoundDirection ~= Vector3.new(1,0,1) then --// FORWARD
						BackwardActive = false
						if self.Running == false then
							if self.WalkBackwardAnimation.IsPlaying then
								self.WalkBackwardAnimation:Stop(.5)
							end
							if not self.WalkForwardAnimation.IsPlaying then
								self.WalkForwardAnimation:Play(.5)
							end
						end
					end
					
					if RoundDirection == Vector3.new(0,0,0) then
						self.IdleAnimation:Play(.5)
						if self.WalkBackwardAnimation.IsPlaying then
							self.WalkBackwardAnimation:Stop(.5)
						end
						if self.WalkForwardAnimation.IsPlaying then
							self.WalkForwardAnimation:Stop(.5)
						end
						
					elseif RoundDirection ~= Vector3.new(0,0,0) then
						self.IdleAnimation:Stop(.5)
						
					end
					

				end

			end
			
			
		end)
4 Likes

Forget it, I already fixed it, and thanks to the people who tried it even though they didn’t reply

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