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: Help with [Square Brackets]

Previous Thread :: Next Thread 
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 Jul 2013 02:58 PM
How do I use [square brackets]? thanks :)

Scripting Tutorials: youtube.com/user/smiley599roblox
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
08 Jul 2013 02:59 PM
Table[Index]
Workspace["Name"]

?
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 Jul 2013 03:16 PM
So I don't need the dots.

If game["Workspace"]?

Scripting Tutorials: youtube.com/user/smiley599roblox
Report Abuse
yomomma128 is not online. yomomma128
Joined: 13 Nov 2008
Total Posts: 23503
08 Jul 2013 03:25 PM
For Workspace and stuff like that, the square brackets pretty much replace findFirstChild

so like instead of....

x = game.Workspace:findFirstChild ("Part")

you could say....

x = game.Worksapce["Part"]
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 Jul 2013 03:33 PM
Could you use it in if statements?

Like

if game.workspace["part"]

Scripting Tutorials: youtube.com/user/smiley599roblox
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
08 Jul 2013 03:36 PM
No, you'd use FindFirstChild. It does not replace find first child.
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 Jul 2013 03:37 PM
So mymomma was wrong?
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
08 Jul 2013 03:40 PM
Yes, you could use it the same as findfirstchild(). It can find a property of the object though instead of finding an actual child, when you might want the child.
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 Jul 2013 03:42 PM
I think Cody is right, sorry. I don't think you know the diferrrence betweena dot and FFC

Scripting Tutorials: youtube.com/user/smiley599roblox
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
08 Jul 2013 03:48 PM
table["Something"] will or will not return nil. game is just a table, and can be used as any other table.

So try this if you dont believe me:

sandbox = {Part = nil,Brick = {Name = "Brick",Properties = "Some properties go here"}}

print(sandbox["Part"])--will return nil
print(sandbox["Part2"])--will also return nil
print(sandbox["Brick"].Name) will return "Brick", you could remove .Name and it will return the table's position.
Report Abuse
yomomma128 is not online. yomomma128
Joined: 13 Nov 2008
Total Posts: 23503
08 Jul 2013 05:25 PM
Just insert a part into workspace called "Billy Bob", then use this script:

game.Workspace["Billy Bob"]:Remove ()

you'll see it works like that.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
08 Jul 2013 05:29 PM
But it does not replace FindFirstChild.

local Part = Game.Workspace:FindFirstChild("Part")

if Part then
print(Part)
end

local Part = Game.Workspace["Part"]
if Part then
print(Part)
end


The second one would error.
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
08 Jul 2013 06:31 PM
My bad then, thought game acted like any other table, but apparently roblox has locked some of it or something.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
08 Jul 2013 06:34 PM
Its not a table. Its a Hierarchy.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
08 Jul 2013 06:59 PM
[ Content Deleted ]
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
08 Jul 2013 07:01 PM
When I asked this myself you said it was a hierarchy... :|
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
08 Jul 2013 07:03 PM
[ Content Deleted ]
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
08 Jul 2013 07:04 PM
Oh. Ok then.
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