How to CFrame A model on top of another

So I have this issue where i have a car spawner, it looks like this: Car video, but with some of the bigger cars it looks like this: Car Video 2, how could i make it so the bigger cars CFrame ontop of the carpet?

1 Like

Hi!

You can do this very easily! :smiley:

Now, set each cars CFrame (when showcasing) to be as following:

-- We just take the Cars Size in the Y axis, and divides it by 2, then we have the middlePoint of the car, and by default the wheels will exactly be touching the ShopPlatForm's CFrame. :D
-- You can then add a little extra like "0.10" like I've done, to make it float a little over the platform if needed, if you don't want that, just remove the "0.10 +" part)
Car.CFrame = ShopPlatform.CFrame + Vector3.new(0, 0.10 + Car.CFrame.Size.Y/2,0)
2 Likes

This works amazingly with a part, but I’m using a group and I cant get the size, do you know any way I can do this?

1 Like

If you’re using a model you could try using model:SetPrimaryPartCFrame(). Here’s the documentation: Model:SetPrimaryPartCFrame

2 Likes

Will that get the size of the group?

1 Like

It basically changes the CFrame of the model, like how you can move models around using your mouse in studio. Maybe for getting the size of the model you could use Model:GetBoundingBox or Model:GetExtentsSize. I recommend you read Roblox’s documentation on models. There’s some useful stuff in there. Model

1 Like

Hi!
Please consider using Pivot

Model:PivotTo(ShopPlatform.CFrame + Vector3.new(0, 0.10 + Car.CFrame.Size.Y/2,0))

https://developer.roblox.com/en-us/api-reference/function/PVInstance/PivotTo
The old way of doing it was how snake_case mentioned it.

2 Likes

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