How to get size of object in a script?

Hello i want to get a the size of a model’s vector.

I tried using

local modelsize, rand = Model:GetBoundingBox()

but this gave me a CFrame resulting to the error:
Unable to cast CoordinateFrame to Vector3 -
How do get the vector of a model similar to this method?

Are you trying to get the cframe or the size?

i said the size (the vector)
eeeeeeeeeeeeeeeee

Ok here.

Print(game.Workspace.YourPartName.Size

Or setting a size

game.Workspace.YourPartName.Size = game.Workspace.AnotherPart.Size

Or if you need the vector, just do

local vectorVal = Vector3.new(4,4,4,4)

Did this help?

1 Like
local cf, size  = Model:GetBoundingBox()
local pos = cf.Position -- position
-- cf -> CFrame
-- pos -> Vector3
-- size  -> Vector3
2 Likes

Thanks for the help! it worked

Thank you for trying to help. In a normal case those might work but they are time consuming, and monotonous

1 Like

https://developer.roblox.com/en-us/api-reference/function/Model/GetExtentsSize
This API method returns a ‘Vector3’ value describing the size of a ‘Model’ instance.

its like 2 more words? but, if you think it helps!

It gets the size of a model without having to save the value in a script. The reason this helps me is because i have 186 models and I dont want to have to save the position of all 186 positions in a script. With his solution i can get get the size in a loop but with yours i would have to save each 186 values manually