Animation stuttering

Hello developers! How can i prevent wait between two animations? Video of the issue and the code will be below.
Code:

takeCameraEvent.OnServerEvent:Connect(function(plr)
	if canTake.Value == true then
		local char = model.Parent
		print(char.Name)
		local hum = char:FindFirstChildOfClass("Humanoid")
		if hum then
			print("Processing animations and visuals.")
			canTake.Value = false
			local anim = hum:LoadAnimation(takeCamera)
			local anim2 = hum:LoadAnimation(holdCamera)
			local anim3 = hum:LoadAnimation(putCamera)
			anim2.Looped = true
			anim:Play()
			inAnimation.Value = true
			anim:GetMarkerReachedSignal("Take"):Wait()
			belt.PrimaryPart.Transparency = 1
			weld.Part0 = char.RightHand
			beltWeld.Part0 = char.UpperTorso
			local cf0 = CFrame.new(0,-model.PrimaryPart.Size.Y/2,0) * CFrame.Angles(math.rad(90),0,math.rad(180))
			weld.C0 = cf0
			anim.Ended:Wait()
			anim2:Play()
			inAnimation.Value = false
			ready.Value = true
			canTake.Value = true
			putCameraEvent.OnServerEvent:Wait()
			canTake.Value = false
			ready.Value = false
			anim3:Play()
			anim2:Stop()
			inAnimation.Value = true
			anim3:GetMarkerReachedSignal("Put"):Wait()
			belt.PrimaryPart.Transparency = 0
			weld.Part0 = char.UpperTorso
			local cf0 = CFrame.new(0,0,-char.UpperTorso.Size.Z) * CFrame.Angles(0,math.rad(180),0)
			weld.C0 = cf0
			anim3.Ended:Wait()
			canTake.Value = true
		else
			warn("Couldn't find humanoid.")
		end
	else
		warn("Can't take the camera.")
	end
end)

1 Like

Firstly, you shouldn’t be doing hum:LoadAnimation() as it’s deprecated. use the Animator object instead, secondly there’s no need to load this animation on the server, it’s a common misconception that players won’t see animations played on the client. So load the animation and play it on the client. Thirdly, the reason why its waiting is because you added waits

By the way if you load and play it on the client it will work smoother and faster than on the server)

It is important for other variables to prevent bugs in animations and code. Also you gave me a mind to run anim2 right after anim1 and now there is no wait. But anyways thank you for your attempt to help!

Oh, maybe i’m stupid then. well ok

1 Like

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