Weird Animation Bug

Hi, I am making this game and I made this Animation/Sprint script but whenever I equip a tool/Sword and run my character gets bugged in a weird way, but when I run without holding any Weapons it plays the animation normally.

I want help fixing it maybe it has to do something with the script and not the Animation

if running then
		local primary_weapon = replicatedstorage.Weapons:FindFirstChild(client_data.PrimaryWeapon.Value)
		if primary_weapon then
			local weapon_type = primary_weapon.Type.Value

			if weapon_type == "Sword" and client_alive:FindFirstChild("Has Weapon") and not saber_sprint.IsPlaying then
				stop_running()
				saber_sprint:Play()
				saber_sprint:AdjustSpeed(1.5)
			elseif weapon_type == "Greatsword" and client_alive:FindFirstChild("Has Weapon") and not greatsword_sprint.IsPlaying then
				stop_running()
				greatsword_sprint:Play()
				greatsword_sprint:AdjustSpeed(1.5)
			elseif not normal_sprint.IsPlaying then
				stop_running()
				normal_sprint:Play()
				normal_sprint:AdjustSpeed(1.5)
			end
		end
	elseif saber_sprint.IsPlaying or normal_sprint.IsPlaying or greatsword_sprint.IsPlaying then
		stop_running()
	end

Video:

3 Likes

What’s the prority of the animation? is it action? Try to set the animation priority to something higher than action.

Thats most likely not the problem. Is this code in a loop?

1 Like

no the priority is Movement and it is in a Loop

dont use a loop, instead make the animation’s looped proprety set to true. and set the priority to action 4

1 Like

If you don’t mind me asking how am I supposed to set Looped Property to true? do you mean the Circle type thing with the arrow inside?

Its a proprety inside the animation instance…

Not sure How I can check that, it does rely on Events though.

… loops include:

while true do

while task.wait() do

runservice.Heartbeat:Connect(function()

runservice.RenderStepped:Connect(function()

1 Like

These are loops, there’s a proprety inside the animation instance called Looped
Set it to true

Only if its an actual animation keyframes thingy. it wont work if its an animation holder

well now that you mention it yes. it uses runservice.Stepped:Connect(Function) and that Sprint part of the script is located inside that function.

I set it to true and false but It didn’t work I couldn’t find Looped but
image
I found a Loop Boolean

first off ur doing 2 loops at the same time, thats just breaking ur code and lagging a lot even if u use runservice, second why are u using a loop for a sprint script?

thats your problem. The animation is playing constantly which is causing it to bug out.

I Didn’t actually make the script I just modified it to work with Different types of weapons so instead of it just doing normal Sprint Anim if the player is holding a weapon and the client script sees that the weapons Type is “Sword” it plays Another Animation instead of the default sprint. and then I don’t understand why the default works while holding a tool doesn’t
Sorry for not saying that I just modified it and didn’t fully script it :pensive:

make a boolean, if its true, play the sprint animation then set the boolean to false.

When the player stops sprinting, set the boolean to true. This is what i usually do for things i only want to fire once in loops.

It only plays the animation if the sprint event is fired the problem is somewhere here

if weapon_type == "Sword" and client_alive:FindFirstChild("Has Weapon") and not saber_sprint.IsPlaying then
				stop_running()
				saber_sprint:Play()
				saber_sprint:AdjustSpeed(1.5)
			elseif weapon_type == "Greatsword" and client_alive:FindFirstChild("Has Weapon") and not greatsword_sprint.IsPlaying then
				stop_running()
				greatsword_sprint:Play()
				greatsword_sprint:AdjustSpeed(1.5)
			elseif not normal_sprint.IsPlaying then
				stop_running()
				normal_sprint:Play()
				normal_sprint:AdjustSpeed(1.5)
			end
		end
	elseif saber_sprint.IsPlaying or normal_sprint.IsPlaying or greatsword_sprint.IsPlaying then
		stop_running()
	end
1 Like

Is sprint fired in a loop?‎ ‎ ‎ ‎ ‎

As you said if it is runservice function its in a Loop so I guess you can say that