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
 

What does this portion of script do?

Previous Thread :: Next Thread 
supereminent is not online. supereminent
Joined: 17 Jul 2011
Total Posts: 523
20 Jan 2016 08:53 PM
I'm looking at a tycoon script, and the first part states:

for i, v in pairs(main.Body:GetChildren()) do
if string.sub(v.Name, 1, 6) ~= "Button" then
if v:findFirstChild("Number") then
table.insert(objects, v)
v.Parent = nil
end

I've been trying to learn scripting in Studio but I can never understand what things like "for i, v in pairs()" does or "string.sub()"

If anyone could help me out with figuring this out, I would greatly appreciate it :)



Report Abuse
supereminent is not online. supereminent
Joined: 17 Jul 2011
Total Posts: 523
20 Jan 2016 09:04 PM
halp



Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
20 Jan 2016 09:18 PM
the for in pairs loop is a loop that looks though a table.
Table = main.Body:GetChildren() -- GetChildren returns a table of all the children of body
for index,object in pairs(Table) do
print(object.Name)
end


string.sub basically takes a section of a string (a string is "hello world") and returns what it is for example
startingCharacter = 1
endingCharacter = 5
print(string.sub("Hello World",startingCharacter,endingCharacter))
-- Hello


startingCharacter = 7
endingCharacter = 11
print(string.sub("Hello World",startingCharacter,endingCharacter))
-- World

what he was doing was checking if the first 6 characters were "Button" and if so it would check if it had a numbervalue in it and if so it will add the button to a table for later use


Report Abuse
supereminent is not online. supereminent
Joined: 17 Jul 2011
Total Posts: 523
20 Jan 2016 09:22 PM
How do you know when to use something like this? I don't think I will ever understand the in-depth statements haha.



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