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 » Scripting Helpers
Home Search
 

Re: Tables / for

Previous Thread :: Next Thread 
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
04 Jul 2012 05:19 AM
Idk how to use tables with for...
Can someone explain to me.
I started making an admin script but I really need to know how this works.
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 05:26 AM
table1 = ("Name", "Name2")

for i, v in pairs(table1) do -- Iterates through table1
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
04 Jul 2012 05:26 AM
Pretty easy:

people = {"blah","Narb","Penguin","bear"}

for number, object in pairs(people) do
print(object.." is #"..number)
end

--Or

for num=1,#people do
print(people[num].." is #"..num)
end
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
04 Jul 2012 05:28 AM
@gg: Why i, v in pairs. I mostly see k, v in pairs?
@zarz: I don't understand...
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 05:32 AM
@koen

i stands as a variable for the loop, just like a numeric for loop does.

I.E: for i = 1, 10 do

So in a generic for loop (which is what you would use for a table), i is the same thing, just used differently.

An example of how a generic for loop is used in a table would be this:

allowed = ("koen500", "Friend") -- Player names that will be 'allowed'.

game.Players.PlayerAdded:connect(function(plr)
for i, v in pairs(allowed) do
if plr.Name ~= v then
plr:Destroy()
end
end)
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
04 Jul 2012 05:32 AM
No diference between k and i.

Just look up the for functions in the wiki.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
04 Jul 2012 05:37 AM
k,i are just variables. It can be anything laik


for apples, pears in pairs(blah) do
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:02 AM
@zars

> pears
> pairs

teeehee
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
04 Jul 2012 06:10 AM
for tiers, pears in pairs(liers) do
print("Wut?")
end
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:11 AM
incorrect

you didn't declare an array/table named liers

liar
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
04 Jul 2012 06:14 AM
Umt i dun wanna give u mah code, cuz u will steal it and claim mah script as urs :( Dun't hurt mah feelings blah QQ~Average person who asks for help, but doesn't give whole code.
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:16 AM
I haven't ever seen someone post something of that sort on SH before.. That would be quite odd.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
04 Jul 2012 06:18 AM
Then you got to be new.... I've seen alot of posts here, asking for help even if they didin't give whole code.
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
04 Jul 2012 06:20 AM
No, I mean that I haven't seen anyone not post code because they don't want it stolen.

I've seen plenty of people who don't post code and expect us to just magically know the issue.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
04 Jul 2012 06:31 AM
Well, of course they don't want to admit that, that they're cowards, but if you think, then yeah that's why... How ironicaly.. People steals others scripts, and are afraid to post theyr own code, because some one might claim copyright of it.
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
04 Jul 2012 08:11 AM
Thanks for the help.
;l
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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