Walking animation is glitchy in game

So my walking animation works in studio but in game, the animation is glitchy.
In Studio:

In Game:

Animate Script: (server script)

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local RunService = game:GetService("RunService")

local runTrack = humanoid:LoadAnimation(script:WaitForChild("Running"))
local walkTrack = humanoid:LoadAnimation(script:WaitForChild("Walking"))
local idleTrack = humanoid:LoadAnimation(script:WaitForChild("Idle"))
local fallTrack = humanoid:LoadAnimation(script:WaitForChild("Fall"))
local jumpTrack = humanoid:LoadAnimation(script:WaitForChild("Jump"))

local function stopAnimations()
	for i,v in ipairs(humanoid:GetPlayingAnimationTracks()) do
		v:Stop()
	end
end

humanoid.Running:Connect(function(speed)
	if math.floor(speed + 0.5) >= 16 then
		stopAnimations()
		if not runTrack.IsPlaying then
			runTrack:Play()
		end
		
	elseif math.floor(speed + 0.5) < 16 and math.floor(speed + 0.5) > 0.75 then
		stopAnimations()
		if not walkTrack.IsPlaying then
			walkTrack:Play()
		end
		
	elseif math.floor(speed + 0.5) <= 0.75 then
		stopAnimations()
		if not idleTrack.IsPlaying then
			idleTrack:Play()
		end
	end
end)

humanoid.FreeFalling:Connect(function(isActive)
	if isActive then
		stopAnimations()
		if not fallTrack.IsPlaying then
			fallTrack:Play()
		end
	end
end)

humanoid.Jumping:Connect(function(isActive)
	if isActive then
		stopAnimations()
		if not jumpTrack.IsPlaying then
			jumpTrack:Play()
		end
	end
end)

Have you tried doing this in a LocalScript instead? If I’m not wrong it will get replicated to the server because characters are always replicating their movement to the server. Or that is only for players idk.

Honestly I do not suggest what you are doing at all. Instead when you play the game you’ll get an Animate script, copy this and turn it into a ServerScript. Minor changes have to be made such as for the emotes and there is no LocalPlayer etc.

Using a script which looks like that would surely work unlike this script. They also have a walking and running animation, but the running animation plays with like 10 or higher walkspeed.