Animation error

I really don’t know how to describe this error
So here 's a video:(I don’t know how to embed video)

External Media

And here’s the code:

--Waiting for player to click button
--Setting up a local veriable

	local Humanoid = game.Players.LocalPlayer.Character.Humanoid
	local animator = Humanoid:FindFirstChild("Animator")
	local animation ="Animation")
	animation.AnimationId = "rbxassetid://17406730342"
	local animationTrack = animator:LoadAnimation(animation)
	local animate = Humanoid.Parent:FindFirstChild("Animate")
	local walk = animate.walk.WalkAnim
	--Checking if player is sprinting
	if Humanoid.WalkSpeed == 16 then
	--Enables sprint
		Humanoid.WalkSpeed = 30 
		walk.AnimationId = "rbxassetid://17406730342"
		script.Parent.Text = "Sprint: On"
		script.Parent.BackgroundColor3 =, 1, 0)
		script.Parent.BorderColor3 =, 0.54902, 0)
	--Disables sprint
		Humanoid.WalkSpeed = 16
		walk.AnimationId = "rbxassetid://17406728769"
		script.Parent.Text = "Sprint: Off"
		script.Parent.BackgroundColor3 =, 0.00712596, 0.0274357)
		script.Parent.BorderColor3 =, 0, 0.00784314)

You should use a variable instead of checking the humanoid walkspeed, not sure if it will fix this or not though.
example code:

local Sprinting = false

	if Sprinting == false then
		Sprinting = true

		game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed = 30
		Sprinting = false

		game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed = 16

Changing the ID associated with the walk animation doesn’t immediately cause a playing walking animation to instead use that new ID. You should utilize two separate animations and play the appropriate one. If you want to keep your current system, you can do a quick hack by stopping all animations after that if statement so the Animate script will use the newly set ID.

(edited to add a possible solution)

I have no idea how you would do that
Can you write me a script for that?

#help-and-feedback:scripting-support isn’t the category to recruit people to script your games. You may need to learn more about how animations work or delegate this task to a collaborator you trust.

1 Like

I think he meant that he wants an example code of that, also it says that you can’t ask people to make entire systems not small scripts like that.

1 Like

This is not necessary anymore I have already found a replacement script for this

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