Animations not replciating to the server properly?

Hello, I have a simple controller that lets you tilt left or right, and lay on the ground. On the client, this works great, everything freezes where it should and stuff, but the server has some issues. Sometimes it freezes, othertimes it freezes at the wrong spot, and sometimes it doesnt freeze or play at all.

Here is an example, left is client, right is server

My code just detects the players input, and plays the correct animation

local context = game:GetService("ContextActionService")
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

local EAnim = character:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("Animations"):WaitForChild("E"))
local QAnim = character.Humanoid:LoadAnimation(script:WaitForChild("Animations"):WaitForChild("Q"))
local CAnim = character.Humanoid:LoadAnimation(script:WaitForChild("Animations"):WaitForChild("C"))
local LAnim = character.Humanoid:LoadAnimation(script:WaitForChild("Animations"):WaitForChild("X"))

local tilted = script.Tilted
local crouched = script.Crouched

local function Q(name, inputState)
	if inputState == Enum.UserInputState.Begin then
		if tilted.Value == "nil" or tilted.Value == "E" then
			QAnim:Play()
			EAnim:Stop()
			QAnim:GetMarkerReachedSignal("Freeze"):Connect(function()
				QAnim:AdjustSpeed(0)
				tilted.Value = "Q"
			end)
		elseif  tilted.Value == "Q" then
			QAnim:Stop()

			tilted.Value = "nil"
		end
	end
end

local function E(name, inputState)
	if inputState == Enum.UserInputState.Begin then
		if tilted.Value == "nil" or tilted.Value == "Q" then
			EAnim:Play()
			QAnim:Stop()
			EAnim:GetMarkerReachedSignal("Freeze"):Connect(function()
				EAnim:AdjustSpeed(0)
				tilted.Value = "E"
			end)
		elseif  tilted.Value == "E" then
			EAnim:Stop()

			tilted.Value = "nil"
		end
	end
end

local function C(name, inputState)
	if inputState == Enum.UserInputState.Begin then
		if crouched.Value == "nil" then
			CAnim:Play()
			
			CAnim:GetMarkerReachedSignal("Freeze"):Connect(function()
				CAnim:AdjustSpeed(0)
				crouched.Value = "1"
			end)
			wait(.2)
		elseif crouched.Value == "1" then
			CAnim:Stop()
			
			LAnim:Play()
			
			LAnim:GetMarkerReachedSignal("Freeze"):Connect(function()
				LAnim:AdjustSpeed(0)
				crouched.Value = "2"
			end)
			wait(.2)
		end
	end
end

local function X(name, inputState)
	if inputState == Enum.UserInputState.Begin then
		if crouched.Value == "2" then
			LAnim:Stop()
			CAnim:Play()

			CAnim:GetMarkerReachedSignal("Freeze"):Connect(function()
				CAnim:AdjustSpeed(0)
				crouched.Value = "1"
			end)
			wait(.2)

		elseif crouched.Value == "1" then
			CAnim:Stop()
			crouched.Value = "nil"
		end
		wait(.2)
	end
end

context:BindAction("Q", Q, false, Enum.KeyCode.Q)
context:BindAction("E", E, false, Enum.KeyCode.E)
context:BindAction("C", C, false, Enum.KeyCode.C)
context:BindAction("X", X, false, Enum.KeyCode.X)

I’ve never seen this issue before and I am quite confused, any help is appreciated!

Edit: Ignore the massive :WaitForChild() spam, the script was erroring without it

1 Like

character.Humanoid:LoadAnimation is deprecated use
character.Humanoid.Animator:LoadAnimation instead

It got deprecated? Since when?? I’ll try this and update you with what happens

Same issue

Edit: The only thing that is changed, is instead of Humanoid:LoadAnimation(), its Humanoid.Animator:LoadAnimation()

why are you adjust animation speed to 0 if so remove it

So the animation can freeze on the right frame, whats happening on the server is that its not freezing

have you set animation priority to action?

Yes the priority is set to action

Bumping to see if anyone else has a solution

maybe try to use remote event or remote function (client to server):

Why would I use remotes? The only issue is the :AdjustSpeed, and it should cross over as it does sometimes

just remove :adjustspeed if your adjust speed is 0

Elaborate please? I have :AdjustSpeed there to freeze the animation, why would I remove that if my whole issue is that the animation is not freezing on the server

so why dont you use a remote event so the animation could replicate to the server properly

Animation Engine - Runtime Changes and Fixes - Updates / Announcements - DevForum | Roblox