Is there a method to refer index of child without a for loop?

title

image
foe example

ControlPanel.MovieConfiguration[1]

i’d want that to return EditMovie; is this possible?

Yes you can do this:

ControlPanel.MovieConfiguration:GetChildren()[1]

This would return the first child, which is EditMovie in this case

1 Like

than kYou
wHat about Trying to get the index of it without a for loop?
for example

print(ControlPanel.MovieConfiguuration.EditMovie)

i’d want that to print 1

You can just use table.find() for this.

table.find(ControlPanel.MovieConfiguration:GetChildren(), asset) --asset is the asset you want to grab the index of

Firing GetChildren() sends you back an array of instances, so you can send that through table.find() to treat it as if it were just a regular table.

1 Like

You can recursively search using findfirstchil.

print(ControlPanel:FindFirstChild('EditMovie', true))
1 Like

In that case you’d want to use what @CapnFry said,
thanks btw for answering their question!

1 Like

To clear confusion, this doesn’t return an index, just the asset itself. Recursively searching using FindFirstChild() more or less just searches through the whole tree it’s being called on.

1 Like

I think getting the asset was the point

1 Like

Thank u
refgdrgjnuidrghjunigrdgrsd

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.