So how would I be able to break this loop immediately when the value is no longer 2?
Would I make another "if then" statement to break the loop?
Like how would I do this (for example)
If Value is (not equal to) ~= 3 then "break"
This is the script I want to do this to.
--Jog Right Animation
SpriteAnimationValue.Changed:Connect(function()
playerframe.ClipsDescendants = true
greenframe.ClipsDescendants = false
local RightJogAnimationSpeed = 0.05
if AnimationValue.Value == 2 then
wait()
playerframe.Size = UDim2.new(0,115,0,118)
playerframe.AnchorPoint = Vector2.new(0,0)
playerframe.Position = UDim2.new(0,0,0,0)
while AnimationValue.Value == 2 do
sonicsprite.Position = UDim2.new(0,-606+17,0,-4)
wait(RightJogAnimationSpeed)
sonicsprite.Position = UDim2.new(0,-769+17,0,-7)
wait(RightJogAnimationSpeed)
sonicsprite.Position = UDim2.new(0,-918+17,0,-7)
wait(RightJogAnimationSpeed)
sonicsprite.Position = UDim2.new(0,-1072+17,0,-7)
wait(RightJogAnimationSpeed)
sonicsprite.Position = UDim2.new(0,-1189+17,0,-7)
wait(RightJogAnimationSpeed)
sonicsprite.Position = UDim2.new(0,-15+17,0,-149)
end
end
end)

1 comment
'break' is actually a lua keyword that you can use to break loops.