Hi, I have a question.
In this image we can see that I have some models and inside of Model “D” is a part,
Let’s imagine that I only know what the model “D” and the part inside are called, how could I know which is the main Model (“A”)
I tried to use FindFirstAntecesor but I stopped because if I don’t have the main part string it can’t search for it
Any help is appreciated
SOTR654
(SOTR654)
September 3, 2021, 1:14pm
#2
If you have the parent of that ancestor, you could use GetChildren
and IsDescendantOf
local Ancestor = nil
local Object =
Folder =
for _,v in pairs(Folder:GetChildren()) do
if Object:IsDescendantOf(v) then
Ancestor = v
break
end
end
Use Instance | Roblox Creator Documentation to find the model ancestor and use a while or repeat loop to keep finding the model ancestor which has a parent equal to the workspace.
2 Likes
But what can i do if i only have the names of “D” and the part
dukzae
(dukzae)
September 3, 2021, 2:11pm
#5
You can place an ObjectValue within “D” and set its value to the main model.
local A = Part.Parent.Parent.Parent
--which is local A = Part.D.B.A
The U can get A with that
If U want to get the name only, use this instead :
local A = Part.Parent.Parent.Parent.Name
--which is local A = Part.D.B.A.Name
try it
1 Like
Sorry if I didn’t explain it well, but I ment how could I get to the main Model without having a specific string for FindFirstAntecesor.
I’m not sure what you mean by a “main model”. What characteristics classify a model as a main model?
Sorry, I was referring to the first model, the one that contains everything.
This would be a good method of achieving what you are trying to go for.
1 Like