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 |
|
|
|
| 08 Jul 2013 02:59 PM |
Table[Index] Workspace["Name"]
? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 08 Jul 2013 03:36 PM |
| No, you'd use FindFirstChild. It does not replace find first child. |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 08 Jul 2013 06:34 PM |
| Its not a table. Its a Hierarchy. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 08 Jul 2013 07:01 PM |
| When I asked this myself you said it was a hierarchy... :| |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
| |
|