When I play one animation on the server then the next it breaks

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make a leaning animation.

  1. What is the issue? Include screenshots / videos if possible!

When I play one leaning animation the other doesn’t work.

Video:

robloxapp-20240127-1206562.wmv (1.4 MB)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried putting the player into the remote event. I looked through multiple posts on the DevHub but none of them worked for me.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Client Script:

if input.KeyCode == Enum.KeyCode.Q and isSprinting == false then

		if isLeaningLeft == false and isLeaningRight == false then

			LeanEvent:FireServer("Left")
			local tween = TweenService:Create(Tilt, tweenInfo, {Value = 15}):Play()

			isLeaningLeft = true

		elseif isLeaningRight == true then

			LeanEvent:FireServer("RightToLeft")
			local tween = TweenService:Create(Tilt, tweenInfo, {Value = 15}):Play()

			isLeaningLeft = true
			isLeaningRight = false

		else 

			LeanEvent:FireServer("None")
			local tween = TweenService:Create(Tilt, tweenInfo, {Value = 0}):Play()

			isLeaningLeft = false

		end
	end

	if input.KeyCode == Enum.KeyCode.E and isSprinting == false then

		if isLeaningRight == false and isLeaningLeft == false then

			LeanEvent:FireServer("Right")
			local tween = TweenService:Create(Tilt, tweenInfo, {Value = -15}):Play()

			isLeaningRight = true

		elseif isLeaningLeft == true then

			LeanEvent:FireServer("LeftToRight")
			local tween = TweenService:Create(Tilt, tweenInfo, {Value = -15}):Play()

			isLeaningLeft = false
			isLeaningRight = true

		else 

			LeanEvent:FireServer("None")
			local tween = TweenService:Create(Tilt, tweenInfo, {Value = 0}):Play()

			isLeaningRight = false

		end

	end

Server Script:


game.ReplicatedStorage.Events:FindFirstChild("LeanEvent").OnServerEvent:Connect(function(player, leanDirection)
	
	local character = player.Character
	local humanoid = character:FindFirstChild("Humanoid")
	local animator = humanoid:FindFirstChild("Animator")
	
	local leanRight = animator:LoadAnimation(leanRightAnim)
	local leanLeft = animator:LoadAnimation(leanLeftAnim)
	
	leanRight:Stop()
	leanLeft:Stop()
	
	print(leanDirection)
	
	if leanDirection == "Right" then
		
		leanRight:Play()
		
	elseif leanDirection == "Left" then

		leanLeft:Play()
		
	elseif leanDirection == "RightToLeft" then
		
		leanRight:Stop()
		leanLeft:Play()
		
	elseif leanDirection == "LeftToRight" then

		leanLeft:Stop()
		leanRight:Play()

		
	else

		leanRight:Stop()
		leanLeft:Stop()
		
	end
	
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Can you make a print statement so that when

elseif leanDirection == "RightToLeft" then
		
		leanRight:Stop()
		leanLeft:Play()
end

it prints some text, to see if the event is really firing

I found the solution. I was just being dumb, thanks for replying!

Can you provide it incase anyone else with the same problem can figure it out?

Yea, I just loaded the animation in the top of the script instead of in the OnServerEvent function.