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
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Question about For Loops

Previous Thread :: Next Thread 
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
16 Oct 2016 11:03 AM
I never really thought about learning the different "methods" of for loops, but I thought that I might as well ask seeing as everyone else in this community knows when and where to use them.

If I was to write a for loop, I would write something like...

for i=1,#workspace:GetChildren()
print(workspace:GetChildren().Name)
end

Although, I'm always seeing things like "ipairs" and "next".

Could someone please explain to me what these mean and how to use them?

Thanks a lot!


Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
16 Oct 2016 11:05 AM
I really messed up the code.

for i=1,#workspace:GetChildren() do
print(workspace:GetChildren()[i].Name)
end


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
16 Oct 2016 11:08 AM
generic for loops and such:

for i = 1,#thing do
print(thing[i].Name)
end

for i = 10,0,-1 do
print(i)
end

for i,v in next, thing do
print(v.Nae)
end

for i,v in pairs(thing) do
print(v.Name)
end

for i,v in ipairs(thing) do
print(v)
end


Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
16 Oct 2016 11:26 AM
www
.
lua
.
org
/
manual
/
5.1
/
manual
.
html
#
2.4.5


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