Animations glitching server-sided

I would like to replicate the animation on the server just like how it is on the client. However, it is bugging out.
Here is the code.

Mouse.Button2Down:connect(function()
	if equipped == true then
		debounce = false
		aiming = true
		if aimdebounce == false then
			aimanimation:AdjustSpeed(1)
			aimanimation:Play()
		end
		game.ReplicatedStorage.gunsystem.cameraswitch:Fire(ignore, true)
		wait(.7)
		while aiming do
			aimdebounce = true
			aimanimation:AdjustSpeed(0)
			wait()
		end
	end
end)
	
Mouse.Button2Up:connect(function()
	if aimdebounce == true then
		shootanimation:AdjustSpeed(1)
		shootanimation.TimePosition = 0
		shootanimation:Stop()
		aimanimation:AdjustSpeed(1)
		aimanimation.TimePosition = 0
		aimanimation:Stop()
		debounce = true
		aiming = false
		shooting = false
		aimdebounce = false
		debounce1 = true
		game.ReplicatedStorage.gunsystem.cameraswitch:Fire(e, false)
	end
end)
	
aimanimation.Stopped:Connect(function()
	if debounce == false then
		aimanimation:Play()
		aimanimation:AdjustSpeed(0)
		aimanimation.TimePosition = aimanimation.Length
	end
end)

Client sided:


Server sided:

1 Like

I’d suggest you to loop the animation instead of doing adjustments every frame. If you want your animation to smoothly blend in, you can just insert a value inside of :Play(), that value will determine how long the blending takes, same works with :Stop()

1 Like

Thank you. I played the actual animation and then the looped version of the last keyframe. It works now.