Is their a way to get the center's position of a grouped object / model?

I’m wondering if their is a way to get the center position of the object, and if you can change it. If yes, how?

1 Like

You could try using :GetBoundingBox()

local function findCenterPos(model)
    return model:GetBoundingBox().Position --//Which is a CFrame
end
2 Likes
  15:11:37.987  local p = workspace:WaitForChild("Model") print(spec:GetBoundingBox().Position):1: attempt to index nil with 'GetBoundingBox'  -  Edit
  15:11:37.988  Stack Begin  -  Studio
  15:11:37.988  Script 'local p = workspace:WaitForChild("Model") print(spec:GetBoundingBox().Position)', Line 1  -  Studio
  15:11:37.988  Stack End  -  Studio

And yes, its a model.

What is spec? It does not seem to be defined anywhere

1 Like

Mb, the origional part was named spec, but I forgot to rename the model to just “Model”.

But now, when I try to change its position, it doesn’t let me.

  15:16:20.987  Position cannot be assigned to  -  Edit
  15:16:20.987  Stack Begin  -  Studio
  15:16:20.987  Script 'local p = workspace:WaitForChild("Model") p:GetBoundingBox().Position = CFrame.new(0, 0, 0)', Line 1  -  Studio
  15:16:20.991  Stack End  -  Studio

To change the origin position of a model, you should use :PivotTo()

function pivot(model : Instance,cf : CFrame)
    model:PivotTo(cf)
end
1 Like

You cannot assign its position. Calling GetBoundingBox() returns the center position and size of the model.

If you’re trying to relocate it, you can use either SetPrimaryPartCFrame or SetPivot methods on the model object.

1 Like

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