In my game there is a skin that is 2D, there is a script inside of a billboardGUI that is used to make it have a walk animation, what ends up happening is that the animation doesn't stop.

Here is the code i wrote:

 	script.Parent.Parent.Parent.Humanoid.Running:Connect(function(speed)
	    if speed > 0 then
			repeat
			script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572147"
			wait(0.2)
			script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572767"
			wait(0.2)
		until speed < 1
	    else
		    script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515571488"
        end
    end)

FIXED CODE:

local running = false

script.Parent.Parent.Parent.Humanoid.Running:Connect(function(speed)
	if speed > 0 then
		running = true
    else
	    running = false
    end
end)

while true do
	if running == true then
		script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572147"
		wait(0.2)
		script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572767"
		wait(0.1)
	else
		script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515571488"
	end
	wait(0.1)
end

1 comment

0

i forgot to mention that the builboardGUI is put inside of the player's HumanoidRootPart.