So given that tables are the quintessential data structuring type in Lua, it's unsurprising that userdata are in essence, tables.
Well, okay, why is this important? You see, the table.key syntax is not, in fact, that "standard" way to create/access entries. Rather, it's a sugarized version of table["key"].
This means that thing.Parent and thing["Parent"] are the same thing, with the latter being what the former is expanded to. So, when it comes time that we need to access a child of a given object, we have the option of doing Object["ChildName"] or Object.ChildName. Either is functionally indistinguishable from the other, it's purely personal preference -- That is, of course, until we need to access an entry/child with a space, at which point we must use the tabe["key"] syntax.
TL;DR:
game.Workspace.ObjectHere & game.Workspace["ObjectHere"] both access the object just fine, but only the game.Workspace["Object Here"] syntax supports objects with spaces in its name.
4 comments
I’ve been wondering this as well, but always just use Parent instead to go around the issue. This is good information!
thanks :3
You can also index it via name Example: game.Workspace["Some Object"].Name
ok cool but what do i do when the thing i want to recall is under two things with spaces in their names? do i just put it next to eachother or what