So anyways I have a script where players can resize their model
now the problem I have is that because resizing changes the pivot point
whenever I use :GetPivot() onto their model whenever they drag
the pivot changes so basically if they resize like 5 upwards on the y axis
everytime they try to pivot it its like 5 studs upwards on the y axis
so I was wondering if there was a way to stop this from happening
and No I do not want any answers that make me use SetPrimaryPartCFrame or all the other deprecated functions
I'm assuming you're using my answer from the previous question. Sadly, you can't change model's pivot offset. However, if you want to get the original pivot, you can create the attributes OriginalPosition, OriginalXDirection, OriginalYDirection, and OriginalZDirection in the model since a pivot (aka CFrame
) has a position and a direction. To get the CFrame
from position and direction, use CFrame.fromMatrix(position, xDirection, yDirection, zDirection)
.
01 | function ScaleModel(model: Model, xScale: number, yScale: number, zScale: number): Model |
02 | local cf, _ = model:GetBoundingBox() |
03 | local origin = cf.Position |
04 |
05 | local OriginalPosition = model:GetAttribute( "OriginalPosition" ) |
06 | if OriginalPosition = = nil then |
07 | model:GetAttribute( "OriginalPosition" , origin) |
08 | OriginalPosition = model:GetAttribute( "OriginalPosition" ) |
09 | end |
10 | local OriginalXDirection = model:GetAttribute( "OriginalXDirection" ) |
11 | if OriginalXDirection = = nil then |
12 | model:GetAttribute( "OriginalXDirection" , cf.XVector) |
13 | OriginalXDirection = model:GetAttribute( "OriginalXDirection" ) |
14 | end |
15 | local OriginalYDirection = model:GetAttribute( "OriginalYDirection" ) |