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