I edited my reply. Please see the changes.
The code itself is fine, works as expected in studio. It must be some other underlying behavior. But the best way to debug a loop is to check your loop invariant on every iteration to ensure that it works as expected. So try printing out rainspawned to try and find the context of why that if statement might be failing.
did u try mine? (30 characters)
If this is the entire script and it prints the statement at the bottom of the script, that means the loop was broken by the if statement and it should stop spawning, meaning the code works as intended
My hypothesis is that you have multiple scripts doing the same thing, but I could be wrong. Do you mind sending a file of your place?
That is really weird. It does seem to stop on my studio. It’s surely something else that’s the problem then.
Please try this, if this doesn’t work I estimate it may be something to do with your end
local rainspawned = 3
while true do
if rainspawned >= 100 then
break
end
rainspawned = rainspawned + 1
wait()
local Rain = Instance.new("Part", game.Workspace)
Rain.Size = Vector3.new(0.5,2,0.5)
Rain.Position = Vector3.new(0,15,0)
Rain.Transparency = 0.5
Rain.Anchored = false
end
print("No More Rain")
No. I only have 1 script trying to break that loop. The script spawns the part and everything.
I feel like its definitely a problem on your end. I tested it and it works flawlessly.
Perhaps you should try restarting studio. The code we’re suggesting to you works fine on our end.
yes this script work for me too
Oh, my gosh. I still restarted studio and it still doesn’t work. The print is still getting outputted, but the parts that are falling are not stopping.
Do you mind sending a place file of your game so we can look into it ourselves?
You have another script creating the parts in an infinite while loop, which is the Instancing
script. If you disable that, everything should be fine. I knew it… so my hypothesis was correct.
I see whats wrong… u got ur script named “Instancing” which generates block for ever, so the block actaully stops but u cant see the difference because of the other blocks spawning by the other script
Oh, my. I should’ve known that. He used the same script, but erased what he had in it. I should changed the name. Ok, let me change the name and I’ll see.