Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Resizing a model or a part changes the PivotPoint in-game?

Asked by 2 years ago

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

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

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).

01function 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")
View all 79 lines...
0
I figured it out, all I had to do was reset the PivotPoint back to the center every single time I moved it but anyways this works too thanks for answering my questions. Overseer_Prince 188 — 2y
0
Also the Model:ScaleTo() function you had mentioned, I have checked it out and I think that functions scales models on 3 axis and it does not give you any options to resize on a single axis. I know this because theres only one parameter that accepts a number so I shouldn't be that excited for that function Overseer_Prince 188 — 2y
0
It's not like that. If you want to scale a model to Vector3.new(50, 50, 50) you can do model:ScaleTo(50) T3_MasterGamer 2189 — 2y
0
And also, you said that "whenever the model scales 5 upwards y axis, pivot also moves 5 upwards y axis" so i thought you were trying to get the previous pivot T3_MasterGamer 2189 — 2y
Ad

Answer this question