How to change position of a model above the part

Hellu! srry for bad english!
I wanna position my model above the part
Capture
(Srry for bad model i’m just practicing lua =] )

local model = game.Workspace.Model
local base = game.Workspace.Base
local halfsize = base.Size.Y/2
model:SetPrimaryPartCFrame(CFrame.new(base.CFrame.Position)+Vector3.new(0,halfsize,0))

Thanks for your time. Have a nice day =]

1 Like

What’s the problem? Is it not working? Are there any error messages?

Your code looks correct so the issue is most likely that the Model | Roblox Creator Documentation isn’t defined or set. Are there any errors in the output that you see? If so what do they say?

Just a side not to let you know that Model | Roblox Creator Documentation will soon be replaced with PVInstance | Roblox Creator Documentation which is a superior version that doesn’t need a Model.PrimaryPart. However, it is still in beta and only usable in studio so for now you are good. In the future however Model:SetPrimaryPartCFrame will be deprecated.

Nope there aren’t any errors…

Model “Model.PrimaryPart” is defined. Could it be possible that it’s because of the bad wielding that i’ve done.

Only the primary part needs to be anchored. All other parts that are welded together in some way need to be directly or indirectly connected to the primary part. They also need to be unanchored.

Also, you forgot to account for the size of the primary part. Try doing this:

local model = game.Workspace.Model
local base = game.Workspace.Base
local halfsize = (base.Size.Y/2 + model.PrimaryPart.Size.Y/2) -- We add half the PrimaryPart's Y size as well

model:SetPrimaryPartCFrame(CFrame.new(base.CFrame.Position)+Vector3.new(0,halfsize,0))
2 Likes

Thank you. Works perfectly fine now. =]