Setting parent of model to part

I am trying to set a Model’s parent to a Part located in the workspace.
I set the parent of the Part to the Model without any errors, but if I check the explorer the Model is clearly not parented to the Part.
I am using this code:

model.Parent = part
print(model.Parent.Name) --This prints the part's name, as if the part is the parent. 
--But after checking in the explorer, the model isn't inside the part.

I have tried looking on the devforum and other places for a solution to this, but none of them have helped me. Thank you for any help!

2 Likes

you need to set the primary part of the model’s CFrame as well.
For example, if you wanted to move a player you set their HumanoidRootPart and the rest of the player follows.

I’ll provide an example but keep in mind this example will only work if you set the model’s primary part in the explorer of the model.

model.Parent = part
model.PrimaryPart.CFrame = part.CFrame
1 Like

That is a good tip, but I don’t need to do that because I checked the explorer and the model was not inside the part at all.

do you have any idea why the model is not being parented to the part properly?

Yes, the issue is that you are parenting it incorrectly.
Instead it should be:

part.Parent = model

Sorry for the misunderstanding earlier

All good.

I want the model to be inside the part, not the other way around. (I know it sounds weird but I need it for my game)

Maybe the model is unanchored and has disabled collisions, so it keeps falling into the void?

Do you mean the part being unanchored?

Not the part, but every part of the model.

yeah good idea, but I tried parenting the model to the workspace and it works fine, but putting it inside the part just makes it disappear. (As I said before I tried printing the parent of the model and it says it is the part, but it’s clearly not)

1 Like

Hmm. Unfortunately I don’t have access to the studio, so I can’t do any tests like I usually do.

Parts are normally parented to models, and not the other way around. Then the models are parented to other part groups/folders/…

Thinking back, I don’t remember ever parenting a model to a part. Have you tried any alternatives? Maybe having a model and parenting to a model?

I have tried alternatives, but for what I am working on I need to parent the model to the part. You can do this in studio regularly, but with the script I used it doesn’t seem to be working.