generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Explain to me the for i=1, 10 do

Previous Thread :: Next Thread 
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 06:49 PM
ive seen for i=
everywhere and in every script and can somone explain it really well i want to understand it 100%



local door = Workspace.Door
for i=1, 10 do
door.Transparency = i/10 -- 1/10, 2/10, 3/10, 4/10... 10/10 (1)
wait() -- wait approximately 1/30 of a second
end



your not who you are when you are who you are trying to be
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 06:54 PM
Help please


your not who you are when you are who you are trying to be
Report Abuse
Ryloxx is not online. Ryloxx
Joined: 20 Sep 2011
Total Posts: 112
15 Sep 2015 06:57 PM
Its just a loop, the for i = 1, 10 part means repeat that action 10 times.
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 07:01 PM
BRB walking across some countries to give this man a cookie

soo its a loop


your not who you are when you are who you are trying to be
Report Abuse
someonedie is not online. someonedie
Joined: 19 Mar 2011
Total Posts: 1710
15 Sep 2015 07:03 PM
i is the number of loops, the first int and second int are minim and max values

Report Abuse
00doggie is not online. 00doggie
Joined: 30 Jul 2009
Total Posts: 337
15 Sep 2015 07:03 PM
well the 'i' will increase by one every time the for loop goes until i is 10 then it ends
thats why it the comment says 1/10 2/10 ... because it is showing that the transparency of the door will increase until it reaches complete transparency
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
15 Sep 2015 07:05 PM
Wow that explanation was garbage.


Here's a good one


The "i" stands for index, its default most people use.

for i = 1,10 do

The first number is what it starts at, in this case it's 1, but it could be anything.
The second number is 10, this is the number the loop stops at,
What we dont see here is the third optional variable, this dictates the step we use, by default its 1.

So it would start at 1, and run the code inside it every time until it hits 10. It changes the i variable to whatever it is currently at.

Like this:


i = 1
*runs code*
i = 2
*runs code*
i = 4
*runs code*
i = 5
*runs code*
i = 6
*runs code*
i = 7
*runs code*
i = 8
*runs code*
i = 9
*runs code*
i = 10
*runs code*
*no more loop running continuing with script*
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 07:06 PM
thanks
my legs hurt i cant deliver any more cookies


your not who you are when you are who you are trying to be
Report Abuse
someonedie is not online. someonedie
Joined: 19 Mar 2011
Total Posts: 1710
15 Sep 2015 07:06 PM
You gave me a donut by accident D:<

WALK BACK
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 07:09 PM
Thanks MrJoey we need more people like you
i didnt really understand the first ones

IF you lived down my street ill give you 10 cookies and a Juice boxs

your not who you are when you are who you are trying to be
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 07:10 PM
box*

sorry i needed fuel to get there and i love chocolate so i ate the cookie


your not who you are when you are who you are trying to be
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
15 Sep 2015 07:10 PM
No problem, I struggled with it for a while too :)
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
15 Sep 2015 07:13 PM
You have 3 main loop statements

for
while
repeat until

The for loop will allow you to increment a variable "i" (but can be any name) from a starting number to an ending number, and you can even adjust the increment value by adding a third parameter. This loop is useful if you know how many repetitions you need.

Example

for count=1,10,2 do
print(count)
end

~ This will count from 1-10 by 2's.


The while loop will will repeat until the condition inside is false, this is useful if you want to constantly repeat something, and is most useful if you don't know how many repetitions you want. CAUTION: you must wait an amount of time or else the while loop will freeze the thread because it's executing very quickly.

Example


count = 0

while(count < 3) do
count = count +1
wait()
end

~This example will increment count until count is equal to 3, and then terminate the loop.


The repeat until loop, this loop acts the same as the while loop except it will ALWAYS run at least once, and keep looping until the condition is false


Example


count = 0

repeat

count = count +1

until count == 3

~ this will increment count at least once, until count is equal to 3




Hope this helped.
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 07:15 PM
I stayed days wondering like WTF he said i know basic scripting but then comes up with unreadable scripts

i thought
i guess ill just have to lay off and stop thinking about scripting but then i found this
page and i understood from it because it was all on one page which just made connecting stuff i just learned eaiser

https://aa586887c09499782847cafb68a197079c3c9807.googledrive.com/host/0BygQW0Uq8-q0eksyMVRXeFFZcmM/base.html?font=two&style=a

THANKS again dude i wish i could do this on you

Game.Player.MrJoeyjoeyJoey.clone()


your not who you are when you are who you are trying to be
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
15 Sep 2015 07:19 PM
Thanks rider that made it easier i didnt know while loops do that

when you said
for count=1,10,2 do
print(count)
end

~ This will count from 1-10 by 2's.



would it count like this? 2 4 6 8 10

your not who you are when you are who you are trying to be
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
16 Sep 2015 12:35 PM
Yes.
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
26 Sep 2015 03:12 PM
@2090

no it wouldnt

It would go

1,3,5,7
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image