Yeah, it didn’t work. The problem has to be with the if statement. It prints out the print statement.
Try changing the wait()
to something like wait(1)
That didn’t work either. The print statement also didn’t get printed.
Did you check the output? Also consider indenting the code and properly formatting it.
The print at the very bottom.
print("The Loop is finished!")
What did you get in output.
local Iter = 0
while true do
Iter = Iter + 1
if Iter >= 50 then break end
local Rain = Instance.new("Part",game.Workspace)
Rain.Size = Vector3.new(0.5,2,0.5)
Rain.Position = Vector3.new(0,15,0)
Rain.Anchored = false
Rain.Transparency = 0.5
wait(0.1)
end
print("Done")
This seems to work. “Done” is printed when it reaches 50. I just realized that making it >= 50
is not necessary since it will stop as soon as it hits 50.
You can change that to
if Iter == 50 then break end
It’s the same exact print. But, the thing is, that the while loop for some reason doesn’t break. Like, the rain keeps falling.
Seems like this is the solution
This didn’t work. The print also didn’t print out in the output.
Are you sure this is a script and not localscript?
I changed my script to look like your’s.
local rainspawned = 0
while rainspawned >= 50 do
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.Anchored = false
Rain.Transparency = 0.5
end
print("The Loop is finished!")
Is the code you provided the whole script? Also are you waiting for it to finish completely? It takes a while for it to stop.
Edit:
You can add a print(Iter)
to see if it really doesn’t stop
local Iter = 0
while true do
print(Iter)
Iter = Iter + 1
if Iter >= 50 then break end
local Rain = Instance.new("Part",game.Workspace)
Rain.Size = Vector3.new(0.5,2,0.5)
Rain.Position = Vector3.new(0,15,0)
Rain.Anchored = false
Rain.Transparency = 0.5
wait(0.1)
end
print("Done")
Yes. The script is implemented into the workspace.
oh and instead of > do < (30 char)
Yes, it’s the same script, and also yes, I am trying to make it stop completely.
local rainspawned = 0
while rainspawned <= 50 do
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.Anchored = false
Rain.Transparency = 0.5
end
print("The Loop is finished!")