Model Positioning

I have been trying to create a script that places models next to each other. But the problem I’m experiencing is that the model doesn’t get set in the right place.

I currently do this
Object2:SetPrimaryPartCFrame(Object1:GetPrimaryPartCFrame() + Object1:GetExtentsSize())

It only works for models with the same size

image
This model gets positioned like I want it to be

image
This model gets a weird offset that I don’t want

I know that something like :GetModelCFrame exists but it’s deprecated and I don’t know how long I can still use it.

1 Like

Perhaps a cleaner solution here would be to put an Attachment into these models at the points where they should connect. Then you can read out the position of these attachments to figure out how to put your train together (i.e. it would be a matter of making sure the attachments overlap).

4 Likes

Okay thanks for the idea I will try that out and I will let you know if it works

Had the same problem as you a long time ago. I highly suggest migrating to WeldConstraints.

1 Like

If you’re looking for the simplest solution it would probably be to just add

Half of train 1 length + half of train 2 length

And that should position them correctly . But attachments are also a good idea.

1 Like

I got it to work with the Attachment idea! Thanks for the help.