While "condition" do
SCRIPT
end
Repeat
SCRIPT
Until "condition"
Isnt the both of them the same they just have to match a condition and keep looping until it matches it. Could anybody tell me the difference? Please help,
While "condition" do
SCRIPT
end
Repeat
SCRIPT
Until "condition"
Isnt the both of them the same they just have to match a condition and keep looping until it matches it. Could anybody tell me the difference? Please help,
in While do if the condition is true it will do it while the condition is true
with until it works a bit different it will do the script until the condition is true
Example: With reapet
Local player = game.Player.LocalPlayer
Local Character
reapet wait()
if player:FindFirstChild("Character") then
Character = player.Character
end until Character
With While do
Local player = game.Player.LocalPlayer
Local Character
while Character == nil do
if player:FindFirstChild("Character") then
Character = player.Character
end
wait()--so loop wont break
end
so basically no difference but in some cases you would rather to use while do and in other cases reapet until
Hello! There isn’t really a big deference, but, they are usually used for different purposes. For example, the while true do loop is usually used to keep doing a condition forever. While the repeat until Loop is used to keep doing something until finished. Take for example this:
local sum = 0
repeat
sum = sum + 2
until sum == 8
Hope it helps.
while true do will it forever or until something you put for instance
while script.parent.transparency = 0 do
wait (3)
print ("hello")
end
wait (10)
script.parent.transparency = 1
then the output it should have one hello but (x2) replace the 2 with however many it dose in about 10 seconds it then will make the transparency = to 1 you can see it stops printing hello but you can still do the same thing with repeat just a different format
repeat print ("hello") and wait (1) until script.parent.transparency = 1
wait (10)
script.parent.transparency = 1
so what I'm thinking so far of my scripting experience is that while ____ do is a loop like repeat but repeat is easier to do one thing rather than while true do so if we were to do many things
repeat wait (1) and print ("hello") and script.parent.brickcolor = brickcolor3.random() untill script.parent.parent = starterGui
wait (10)
script.parent.parent = game.starterGui
but while do is
while script.parent.parent = workspace do
wait (1)
print ('hello")
end
wait (10)
script.parent.parent = starterGui
so my concudion is that use repeat for one to 3 things but while is for multible becuase repeat dosent look nice and i think that means somthing becuase if for some reson you wanted to edit it it would be harder to find
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
There really isn't a difference besides being able to do short repeats like "repeat wait() until blank", I tend to use while loops more because other language like java its simpler.
https://developer.roblox.com/en-us/articles/Loops