cus @MCAndRobloxUnited said it is possible; and also gave a convincing reason.
local part = Model:GetChildren().Part
cus @MCAndRobloxUnited said it is possible; and also gave a convincing reason.
local part = Model:GetChildren().Part
This discussion is preserved as it was. New answers, comments, and votes are closed.
15 comments
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.
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).
so ur stating that Model:GetChildren().Part == Model:GetChildren("Part")??? or??
No, I am saying Model:GetChildren()["Part"], where :GetChildren() returns a table.
and that ["Part"] == .Part??
Yes.
Well, not ==, but it has the same syntactical functioning in Lua.
GetChildren returns an array and arrays have numerical indices, "Part" is a string index, making it nil.
Yes
I do not think that this will work. "Model:GetChildren()" only returns a table.
https://scriptinghelpers.org/blog/common-mistakes#GetChildren
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().
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.
If a table has a value at the index "Part" then yes, .Part would work the same as ["Part"].
ok thx