Set an animated image based if the player is moving

Sorry to bother you again, but this isn’t working properly.

humanoid.Running:Connect(function(speed)
while wait() do
if speed == 0 then
running = false
script.Parent.Texture.Decal.Texture = “rbxassetid://5813736561”
break
else
running = true
script.Parent.Texture.Decal.Texture = “rbxassetid://5813744107”
wait(0.25)
script.Parent.Texture.Decal.Texture = “rbxassetid://5813736561”
wait(0.25)
script.Parent.Texture.Decal.Texture = “rbxassetid://5813744553”
wait(0.25)
script.Parent.Texture.Decal.Texture = “rbxassetid://5813736561”
wait(0.25)
end
end
end)

It plays the different frames, but doesn’t end.

Try this

local running = true
while wait() do
script.Parent.Texture.Decal.Texture = “rbxassetid://5813744107”
wait(0.25)
script.Parent.Texture.Decal.Texture = “rbxassetid://5813736561”
wait(0.25)
script.Parent.Texture.Decal.Texture = “rbxassetid://5813744553”
wait(0.25)
script.Parent.Texture.Decal.Texture = “rbxassetid://5813736561”
wait(0.25)

humanoid.Running:Connect(function(speed)
if speed == 0 then
running = false
script.Parent.Texture.Decal.Texture = “rbxassetid://5813736561”
break
else
end
end
end
end)

Says a break statement must be inside a loop

ill try to figure it out, if I can’t, ill let ya know! Thank you!

Put the while wait() do under the local running = true at the top.

If that doesn’t work man, I’m sorry!

It didn’t work, I really appreciate you being here to help! Its 100% not your fault!

2 Likes

I just reproduced the script, here is my result try it! Let me know if it works.

local running = nil

humanoid.Running:Connect(function(speed)
	if speed >= 0 then
		running = true
	end	
end)

humanoid.Running:Connect(function(speed)
	if speed == 0 then
		running = false
	end
end)


    while wait(0.1) do
    	if running == true then
    		
    		script.Parent.Texture.Decal.Texture = "rbxassetid://5813744107"
    		wait(0.25)
    		script.Parent.Texture.Decal.Texture = "rbxassetid://5813736561"
    		wait(0.25)
    		script.Parent.Texture.Decal.Texture = "rbxassetid://5813744553"
    		wait(0.25)
    		script.Parent.Texture.Decal.Texture = "rbxassetid://5813736561"
    		wait(0.25)
    	elseif running == false then
    		script.Parent.Texture.Decal.Texture = "rbxassetid://5813736561"
    		break
    	end
    end

It plays the walking animation, but doesn’t stop. But the good news is it doesn’t glitch out and duplicate the animation!

1 Like

For some reason, by break for loops never really works. Idk why, xD

2 Likes

Yeah I just thought I’d try it and see if it works, but it’s good that it doesn’t glitch out, nor duplicate the animation, I’m literally on your level for coding don’t worry :joy:

I will figure out a way tomorrow as it’s three am for me, unless you do it by then!

1 Like

Oh, alright! I appreciate everything you have done for me! Thank you!

1 Like

Of course, no problem. 20chars

I did it! I simply cloned a loop script into the player and then removed it when the player stopped moving! Thank you so so so much for all the help!

1 Like

No problem man, I’m glad you did it :sunglasses::slight_smile:

1 Like