Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

guys this is not possible right?: Model:GetChildren().Part

Asked by 5 years ago
Edited 5 years ago

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

local part = Model:GetChildren().Part
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. User#25115 0 — 5y
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).  User#25115 0 — 5y
0
so ur stating that Model:GetChildren().Part == Model:GetChildren("Part")??? or?? TheluaBanana 946 — 5y
0
No, I am saying Model:GetChildren()["Part"], where :GetChildren() returns a table. User#25115 0 — 5y
View all comments (11 more)
0
and that ["Part"] == .Part?? TheluaBanana 946 — 5y
0
Yes. User#25115 0 — 5y
0
Well, not ==, but it has the same syntactical functioning in Lua. User#25115 0 — 5y
1
GetChildren returns an array and arrays have numerical indices, "Part" is a string index, making it nil. User#24403 69 — 5y
0
Yes ee0w 458 — 5y
0
I do not think that this will work. "Model:GetChildren()" only returns a table. OptimisticSide 199 — 5y
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(). User#25115 0 — 5y
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. User#25115 0 — 5y
1
If a table has a value at the index "Part" then yes, .Part would work the same as ["Part"]. User#25115 0 — 5y
0
ok thx TheluaBanana 946 — 5y

Answer this question