So what I mean by this is how would I find all the children named 'THIS' in this model? And if it is called 'THIS' execute this function?
I know how to find all the children of a part but don't know anything past that...
local children = model for i = 1, #children do --if childs names is THIS then --rest of code
Of course, if there is a more efficient way that would be appreciated.
Here I suppose you know how to get the children of the model already so i will just leave that for you to write, store it in the table i named "children"
for i =1,#children do wait() if children[i].Name == "this" then--your if statement print("this is found at index"..i)--this code will run if the part is named this, and shows you the index of the part in the table else print("this is not found at index"..i)--this code will run if the part is not named this, and shows you the index of the part in the table end end
Alternatively with the in pairs loop, both will work
for i,v in pairs(children) do if v.Name == "this" then print("this is found at index"..i) else print("this is not found at index"..i) end end