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:
01 | script.Parent.Parent.Parent.Humanoid.Running:Connect( function (speed) |
02 | if speed > 0 then |
03 | repeat |
04 | script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572147" |
05 | wait( 0.2 ) |
06 | script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572767" |
07 | wait( 0.2 ) |
08 | until speed < 1 |
09 | else |
10 | script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515571488" |
11 | end |
12 | end ) |
FIXED CODE:
01 | local running = false |
02 |
03 | script.Parent.Parent.Parent.Humanoid.Running:Connect( function (speed) |
04 | if speed > 0 then |
05 | running = true |
06 | else |
07 | running = false |
08 | end |
09 | end ) |
10 |
11 | while true do |
12 | if running = = true then |
13 | script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572147" |
14 | wait( 0.2 ) |
15 | script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=5515572767" |