Hey, I am kind of stumped right now because using a break doesn’t stop the loop. I have tried using a RenderStepped connection and disconnecting it but that didn’t work either. It is strange because normally it always stops whenever I use the same method. Here is a snippet of my code:
function startMoving(coin)
while true do
if coin and destroyedParts[coin] == nil then
move(coin)
else
break
end
wait(0.1)
end
end
Could it be that roblox is down right now? I have seen other posts describing weird errors but on the status page it says everything is fine.
Break only breaks out of the first code block around it. In this case, it might be breaking the if statement. You’ll need a variable and set the while loop to while variable == true and set it to false in the else
Ah okay. I never knew that. Will roblox automatically break the loop if the conditions are not met. If not, how would I do that without using another if statement (because that would lead to the same issue)?
coin must be a false value or destroyedParts[coin] must be a true value to break the loop.
If coin exist and you find “coin” in this table, so the loop wont break. Could you show a print of the function move(coin)? So we can check the modifications and fix.
The thing is that I put a print over the break to see if it would register the coin being nil. It printed perfectly, so I am pretty sure that is not the problem.
Fixed it myself. I switched to a renderstepped event and disconnected it when the conditions were met. For some reason I had to manually set the coin to nil but hey, it works. Thank you all for the help!