|
| 29 Mar 2016 01:27 PM |
Im reading the wiki and the example of looping they give confuses me.
number = 0 while true do number = number + 1 print(number) wait(1) end |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2016 01:28 PM |
while true do print("Hey") wait(1) end
that would print "Hey" every 1 second because loops just go back to the start of the scope
#code R+ | local RAP = "R$384,047"; local robux = "R$1,572" |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2016 01:29 PM |
Initially, it sets the variable 'number' to 0, then it will:
- 1. add one to number - 2. print it - 3. wait 1 second - 4. go back to step 1 |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2016 01:31 PM |
Lets break it down.
number = 0 -- This is a variable that holds a number.
while true do -- This is the start of the loop, Basically it says Repeat loop until true. This could be extended upon like "while number < 50 do", so it repeats until the number 50 or higher. Since it is checking if the number is Less than 50.
number = number + 1 -- This is adding 1 to the number variable, so every time this loop runs, it adds 1.
print(number) -- This just outputs/prints the number to the console/log
wait(1) -- Wait is literally to wait in seconds. In this case, 1 second.
end -- This end is the end of the loop, basically ends the block of code. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2016 01:35 PM |
| All of these were very helpful thanks! |
|
|
| Report Abuse |
|
|