[SOLVED] Animation wont play, and walk speed wont revert back

Hello,

I am trying to make a sprint system for my friend’s game which plays an animation and changes the walkspeed; It works so far but the only part I am having trouble with is the Walk Speed and Animation part. The Animation won’t play and the walk speed will not revert to normal.
Here’s the Client-Sided Script:

local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("RunEvent")

local runAnim = workspace:WaitForChild("RunAnimation")

local UIS = game:GetService("UserInputService")

local running = false

local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()

local char = plr.Character or plr.CharacterAdded:Wait()

UIS.InputBegan:Connect(function(input,gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.LeftControl or input.KeyCode == Enum.KeyCode.RightControl then
		running = true
		if running then
			local humanoid = char:WaitForChild("Humanoid")
			local animator = humanoid:WaitForChild("Animator")
			event:FireServer(humanoid,animator,runAnim,running)
		else
			print("Not running.")
		end
		UIS.InputEnded:Connect(function(i)
			if i.KeyCode == Enum.KeyCode.LeftControl or i.KeyCode == Enum.KeyCode.RightControl then
				print("Ended.")
				running = false
			end
		end)
	end
end)

Server-Sided Script:

local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("RunEvent")

local NORMAL_SPEED = 16

event.OnServerEvent:Connect(function(p,humanoid,animator,runAnim,running)
	humanoid.WalkSpeed = 25
	local animationTrack = animator:LoadAnimation(runAnim)
	animationTrack:Play()
	if not running then
		humanoid.WalkSpeed = NORMAL_SPEED
		animationTrack:Stop()
	end
end)

Anyways, help is very much appreciated by me. Thank you and have a nice day.

I thought animations only are performed using local scripts on a player?

You should not change walkspeed on a serverscript it’s just inconvenient

Also you never fire another event to let it know running is false that is why your walkspeed wont revert back

Animation still wont play.

sdfsdfds

Tried to change it on the local script but didnt work.

This entire running system should be local it will all replicate anyways. Also the animation is probably not working because the priority of your running animation is low.

Ok, maybe thats why the animation isnt working, but why isnt the walk speed reverting back?

Ok, I fixed it.

sdfsdfdsfdsfds

1 Like

Please mark your post as the Solution and let everyone know how you fixed it so others can read your Solved post and learn from it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.