Hello guys. I have a script that "stops" working after decreasing to the intended value (0 "zero"), but it doesn't stop working after reaching it.
Here's the repeat loop:
local x = 8.5 repeat wait(0.2) script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(x,0,0) x -= 0.1 until x == 0 script.Disabled=true
I think my problem starts after the "until" because it doesn't stop after reaching the intended value. I tried putting that, didn't work, as usual...
until x == 0 script.Disabled=true
What should I type instead to make it work?
I would suggest you use for loop on this situation, since it only loops for a specific value and returns index value too. And it's more useful since it might fix your problem!
for x = 8.5, 0, 0.1 do wait(0.2) script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(x,0,0) end
I've deleted the line of disabling own script. Since you cannot enable it back because you disabled the script and it stopped to run. Just leave it like that since it's the end, it won't execute anything!
Ok guys so, I fixed the problem myself.
First off, I used "while wait() do" instead (idk if the "repeat until" was the main problem).
Second, I changed;
until x == 0 script.Disabled=true
to this:
if x < 0.2 then script.Disabled=true break end
because the X number never reaches to 0. So I used "less-than 0.3" instead of "equals to 0". It works pretty well now.
Here's the whole script:
local x = 8.5 while wait() do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(x,0,0) script.Parent.Parent.EngineWheel2.CFrame = script.Parent.Parent.EngineWheel2.CFrame * CFrame.Angles(x,0,0) x -= 0.05 if x < 0.2 then script.Disabled=true break end end