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

Re: What are the square brackets for?

Previous Thread :: Next Thread 
samthemagicman is not online. samthemagicman
Joined: 20 Mar 2011
Total Posts: 1225
05 Jun 2014 09:33 AM
Hi.

I've seen the square brackets [] with some text in them in some scripts, and I can't find anything on the wiki about them.

So I just wanna know what they're for?

Thanks.
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
05 Jun 2014 09:41 AM
They are often used to define a variable..

For example, one of my scripts use

for i, q in pairs(v[script.Parent.Parent.MannequinChoice.Value][" "]:GetChildren()) do

Square brackets are also used if there is a space in a model or parts name.

If a parts name was "Part 1", you couldn't do:
workspace.Part 1.Transparency = 1

You would need to type workspace["Part 1"].Transparency = 1
Report Abuse
samthemagicman is not online. samthemagicman
Joined: 20 Mar 2011
Total Posts: 1225
05 Jun 2014 09:42 AM
I already knew that, but thanks for trying.

It's something like, in the midi player gamehero made, he uses [Enter midi data here] thing..
.3.?
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
05 Jun 2014 09:45 AM
"I already knew that, but thanks for trying"

"trying"

How was he "trying" by asnwering your question? Just because someone uses them in a string for starter text, doesn't mean he defined it wrong.
Report Abuse
samthemagicman is not online. samthemagicman
Joined: 20 Mar 2011
Total Posts: 1225
05 Jun 2014 09:49 AM
Accomplish, I'm not trying to start a flame war, so don't try either.
Report Abuse
samthemagicman is not online. samthemagicman
Joined: 20 Mar 2011
Total Posts: 1225
05 Jun 2014 09:52 AM
Lol, sorry. So is it just used for text? Like ""?
Report Abuse
samthemagicman is not online. samthemagicman
Joined: 20 Mar 2011
Total Posts: 1225
05 Jun 2014 09:59 AM
Ugh, I'm still half asleep ;-;

Forget this post, I figured it out.
Report Abuse
ajmhm1111 is not online. ajmhm1111
Joined: 22 Jun 2013
Total Posts: 164
05 Jun 2014 10:02 AM
Hello,

I only know 2 ways for []

The first is for accessing a value in a table.

local tab = {1,2,3}

print(tab[2]); --> 2

You can also use it for accessing Instances where their name has a space in it.

For example

Instance.new("Part",Workspace).Name = "This is a part"
print(Workspace["This is a part"].Name) -->This is a part

Hope this helps
--ajmhm1111
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
05 Jun 2014 10:04 AM
The first is for accessing a value in a table.
You can also use it for accessing Instances where their name has a space in it.

They are both the same thing. Every instance is a table.
Report Abuse
ajmhm1111 is not online. ajmhm1111
Joined: 22 Jun 2013
Total Posts: 164
05 Jun 2014 10:09 AM
Don't blind me with knowledge :)

--ajmhm1111
Report Abuse
samthemagicman is not online. samthemagicman
Joined: 20 Mar 2011
Total Posts: 1225
05 Jun 2014 10:12 AM
Sorry, it's not like this [] it's actually like this [[]] and it makes the text that you put in the middle purple. ;3
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