Weird run animation

Hi! I’m trying to make a remastered prison life game, but I’ve got a problem.
When running, the animation on the server is a bit weird. For example:
This is what the client sees.
https://cdn.discordapp.com/attachments/932648931408637993/933519723365269554/2022-01-19_19-33-18.mp4

This is what the server sees.

My state handler:

local RequireService = require(game.ReplicatedStorage.Lib.RequireModule);

repeat
    wait(1)
until script.Parent:FindFirstChild("Head")

local Player = RequireService("Players").LocalPlayer;
local UIS = RequireService("UserInputService");
local Animate
local Humanoid = Player.Character:FindFirstChild('Humanoid');

local States = {
    ["Crouch"] = false;
    ["Run"] = false;
}

local QueueOnWalk = {}

local Anims = {
    ["CrouchIdle"] = Humanoid:LoadAnimation(script.CrouchIdle);
    ["CrouchWalk"] = Humanoid:LoadAnimation(script.CrouchWalk);
    ["CrouchIdleR6"] = Humanoid:LoadAnimation(script.CrouchIdleR6);
    ["CrouchWalkR6"] = Humanoid:LoadAnimation(script.CrouchWalkR6);
    ["Run"] = Humanoid:LoadAnimation(script.Run);
    ["RunR6"] = Humanoid:LoadAnimation(script.RunR6);
}

local IsR6 = Humanoid.RigType == Enum.HumanoidRigType.R6;

local Char = script.Parent;

-- PC
UIS.InputBegan:Connect(function(Input, Typing)
    local IKC = Input.KeyCode;
    local KC = Enum.KeyCode;

	if IKC == KC.LeftControl then

		Char.Animate.idle["Animation1"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
		Char.Animate.idle["Animation2"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
		Char.Animate.walk.WalkAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;
		Char.Animate.run.RunAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;

		Humanoid:ChangeState(Enum.HumanoidStateType.Landed)

        States.Run = false;
        States.Crouch = true;
        Humanoid.WalkSpeed = 8;
    end

    if IKC == KC.LeftShift then
		Char.Animate.walk.WalkAnim.AnimationId = Anims.RunR6.Animation.AnimationId;
		Char.Animate.run.RunAnim.AnimationId = Anims.RunR6.Animation.AnimationId;

		--table.insert(QueueOnWalk, "LandedState")
		RequireService("TweenService"):Create(workspace.CurrentCamera, TweenInfo.new(.5), {FieldOfView = 90}):Play()
		Humanoid:ChangeState(Enum.HumanoidStateType.Landed);

        Humanoid.WalkSpeed = 25;
        States.Run = true;
    end
end)

UIS.InputEnded:Connect(function(Input, Typing)
    local IKC = Input.KeyCode;
    local KC = Enum.KeyCode;

    if IKC == KC.LeftControl then

		Char.Animate.idle["Animation1"].AnimationId = "rbxassetid://8420915727"
		Char.Animate.idle["Animation2"].AnimationId = "rbxassetid://8420915727"
		Char.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8420926467"
		Char.Animate.run.RunAnim.AnimationId = "rbxassetid://8420926467"

        Humanoid:ChangeState(Enum.HumanoidStateType.Landed);
        States.Crouch = false;
        if States.Run == true then
            Humanoid.WalkSpeed = 25;
        else
            Humanoid.WalkSpeed = 16;
        end
    end

    if IKC == KC.LeftShift then
		Char.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8420926467"
		Char.Animate.run.RunAnim.AnimationId = "rbxassetid://8420926467"
		
		--table.insert(QueueOnWalk, "LandedState")
		RequireService("TweenService"):Create(workspace.CurrentCamera, TweenInfo.new(.5), {FieldOfView = 70}):Play()
		Humanoid:ChangeState(Enum.HumanoidStateType.Landed);

        Humanoid.WalkSpeed = 16;
        States.Run = true;
    end
end)

Humanoid.Running:Connect(function(spd)
	if spd > 0 then
		-- lol
	end
end)

--[[ ignore!!! ]]
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

function animationPlayed(anim)
	local name = anim.Name:lower() -- Get the name of the animation in all lowercase, helps with finding the name.
	if name == "toolnoneanim" or name:find("tool") then		-- "toolnoneanim" is the name of the tool equip animation, if Roblox happens to change the name it'll look for "tool" in the name.
		anim:Stop()
	end
end

humanoid.AnimationPlayed:Connect(animationPlayed)

I’m trying to get it to stop playing that run animation when the player stops running. Any help?

2 Likes

Roblox pushed an update about a year ago to make Humanoid:LoadAnimation deprecated. To eliminate any possibilities of issues that the roblox function caused, could you port your animation loading code over to Humanoid.Animator:LoadAnimation and see if the issue is still there?

local Anims = {
    ["CrouchIdle"] = Humanoid:LoadAnimation(script.CrouchIdle); -- Humanoid.Animator:LoadAnimation(script.CrouchIdle);
    ["CrouchWalk"] = Humanoid:LoadAnimation(script.CrouchWalk);
    ["CrouchIdleR6"] = Humanoid:LoadAnimation(script.CrouchIdleR6);
    ["CrouchWalkR6"] = Humanoid:LoadAnimation(script.CrouchWalkR6);
    ["Run"] = Humanoid:LoadAnimation(script.Run);
    ["RunR6"] = Humanoid:LoadAnimation(script.RunR6);
}

https://developer.roblox.com/en-us/api-reference/function/Humanoid/LoadAnimation

1 Like

Yeah, tried it and it still happens.
Alsooo… I play the animations like this:

Char.Animate.idle["Animation1"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
Char.Animate.idle["Animation2"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
Char.Animate.walk.WalkAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;
Char.Animate.run.RunAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;
		
stopTracks()
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)

the stopTracks function:

function stopTracks()
	Char.Animate.Disabled = true;
	wait()
	Char.Animate.Disabled = false;
end

Use Animator:LoadAnimation(). Also maybe try remote:FireServer() then do the animation in the server. Cheers!

I’m already using Animator, and on the script that I’m using, it uses Chr.Animate to set the idle, run, and walk animations so they replicate to the server. I need it to stop playing on the server clients, not just my client.

Sorry for the late followup. I didn’t get a chance to see this until now.

Char.Animate.idle["Animation1"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
Char.Animate.idle["Animation2"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
Char.Animate.walk.WalkAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;
Char.Animate.run.RunAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;

You are trying to overwrite the AnimationID locally. While your client animation ID is constantly changing and you’re seeing results for it, the server’s copy isn’t changing. I’m assuming the initial animation has a blank ID, leading to the default pose. Your animation isn’t being changed on the server as you move around.

I would recommend to not change the animation ID, and, instead, create separate animation objects and play each one accordingly. Playing the animation will replicate to the server, while changing the ID will not.

1 Like

The issue has been fixed, I have moved everything to server, instead of client.

That’s what I was trying to say, lol.