Hi,

I need to deform model, so it will be same in axis and in axis smaller or bigger.

could you give some more detail on what you want to do, providing pictures really help.

Are you trying to resize a model, relocate it or both? Relocating a model is easier than scaling it but scaling it also isn’t too hard.

from this (ok this is only cube, but think, that it is model):

make this:

so i need to scale it, but deform it, not scale all axis same

I see! I thought you meant a Model as in a Roblox Model rather than a Mesh. If you use a MeshPart you can do this. The MeshPart can have the mesh and you can set the size of the MeshPart to stretch the mesh.

yes, i thought model, but i had opened MAYA2019 and roblox started to upgrade, so i took screenshots in maya

Okay! To stretch an entire model you need to loop through the model using `Model:GetDescendants()`

for all of the parts you want to get their CFrame relative to the center of the model.

To get the center of the model you can use the GetBoundingBox function.

Then you can use this to remove the model’s location. That will get the location including rotation relative to the model’s center.

```
part.CFrame * modelCFrame:Inverse()
```

Now if you want to make the model twice as tall (multiply the size by `Vector3.new(1, 2, 1)`

) you need to move the part’s relative Y position to be twice as high and make the part’s Y size twice as high.

```
local scale = Vector3.new(1, 2, 1) -- How much to multiply the size by (this will be twice as tall)
local relativePosition = part.CFrame * modelCFrame:Inverse()
local newPosition = relativePosition + relativePosition.Position * scale
part.CFrame = newPosition * modelCFrame
part.Size = part.Size * scale
```

and what will do this, this:

or this (what i need)

(in first example, it will scale with same centers position, in second example, it will scale with same lowest points position)

To make the model scale upwards you will need to relocate the model up by half of its new size minus its old size and finally minus the old position of the part. GetBoundingBox also gives you the size of the model.

```
-- Before you resize
local oldPosition, oldSize = model:GetBoundingBox()
-- After you resize
local newPosition, newSize = model:GetBoundingBox()
local changeInSize = newSize-oldSize
-- Now you can loop through all your parts again
part.CFrame = part.CFrame + changeInSize/2 - oldPartPosition
```

And when i need to tween it???

To tween it you can use TweeService:GetValue and RunService.Heartbeat:Wait(). Then you’d call your resize code in a loop.

Here is the code for other people who need it

This code allows you to deform the model scale like a mesh:

make sure the face direction of each part is correct

```
local function Deform_Model(model)
local scaleReference = Vector3.new(1,2,2)
local originalCFrame = model:GetPrimaryPartCFrame()
local originalSize = model:GetExtentsSize()
--needs to rotate to avoid wrong distortions
local newRotation = CFrame.new(Vector3.new())
model:SetPrimaryPartCFrame(newRotation)
local modelCFrame = model.PrimaryPart.CFrame
for _, part in pairs(model:GetDescendants()) do
if part:IsA("BasePart") then
local relativePosition = modelCFrame:pointToObjectSpace(part.Position)
local newPosition = modelCFrame:pointToWorldSpace(relativePosition * (scaleReference / originalSize))
part.CFrame = CFrame.new(newPosition)
part.Size = part.Size * (scaleReference / originalSize)
end
end
model:SetPrimaryPartCFrame(originalCFrame)
local pivotOffset = model:GetBoundingBox() - model.PrimaryPart.Position
model.PrimaryPart.PivotOffset = pivotOffset
end
Deform_Model(workspace.Model)
```