I’m having an issue with a script that is updating parts and models to new versions. The issue that I’m running into is that all the new models have pivot offsets which are not zero. Because of this, the models are off the ground by the pivot amount. Here is the code that I’m using for both parts and models:
if model == true then
-- Model
local mpp = ammo.PrimaryPart.PivotOffset.Position + pos
local cf = CFrame.new(mpp) * CFrame.Angles(ox, oy, oz)
aclone:PivotTo(cf)
else
-- Part
local ppo = ammo.PivotOffset.Position
aclone.Position = pos + ppo
aclone.Orientation = orient
end
And this is the result:
As you can see, the item on the right is levitated off the ground by 1/2 the vertical size of the model. The pivot points on all the new models is at the bottom of the model. The actual number varies for each model. The pivot of the original models is at (0, 0, 0). What is interesting is that the code for part is working correctly. Now I read that models use the pivot of the primary part, and what’s what I’m using, but it’s not working. It’s at the position of the original model with the pivot position offset set to (0, 0, 0). How do I fix this?
pos is the position of the original model.
I am running this from a script on the command line in studio. There’s a bunch of models that needs to be replaced and this was the easiest way to do it.