cus @MCAndRobloxUnited said it is possible; and also gave a convincing reason.

local part = Model:GetChildren().Part

15 comments

1

Yes, it is possible. In Lua, .Part is the same as ["Part"] and the :GetChildren() method returns a table. Thus, MCAndRobloxUnited is correct in the syntax, but not the actual implementation.

0

That will not work if "Part" is not an index. Because :GetChildren() returns an array of the objects where the values in that array are the objects, if you try to index "Part," the variable part will be nil (Note: The array is numerically indexed). 

0

so ur stating that Model:GetChildren().Part == Model:GetChildren("Part")??? or??

0

No, I am saying Model:GetChildren()["Part"], where :GetChildren() returns a table.

0

and that ["Part"] == .Part??

0

Yes.

0

Well, not ==, but it has the same syntactical functioning in Lua.

1

GetChildren returns an array and arrays have numerical indices, "Part" is a string index, making it nil.

0

Yes

0

I do not think that this will work. "Model:GetChildren()" only returns a table.

1

Some people have been pointing out the possible confusion that may result from my comments. When I say that :GetChildren() returns a table, I am referring to an array. The "table" type in Lua encompasses arrays, dictionaries, etc. I would also like to clarify that :GetChildren() returns a numerically indexed array, so doing .Part would NEVER work with :GetChildren().

1

Trying to get the value at the index of a string in a table that either 1.) is numerically indexed or 2.) has no ["Part"] index will result in a nil value.

1

If a table has a value at the index "Part" then yes, .Part would work the same as ["Part"].

0

ok thx