(I posted this issue in a wrong topic, so imma have to rewrite this again.)
I have been scratching my head for 2 days straight finding a solution for an accurate scaling formula.
I want to achieve the scaling of just the limb, not the entire character.
I have tried atleast 3 method.
- Standard scaling by simply apply the scale to the joint.
- using the height of the part / 2 and offset it with attachment’s origin
- Copy the same method used for R6. (identical result to method 1)
What I got so far. (method 2)
They’re never centered and was squashed or straight up bumping out
Scale : 1,3,1
Scale : 0.5,0.5,1
This script is a heavily modified version of the code made by EchoReaper.
part.OriginalSize.Value = part.OriginalSize.Value * scaleFactor
local lastPartSize = part.Size
part.Size = part.Size * scaleFactor
for _,attachment in pairs(part:GetChildren()) do
if attachment:IsA("Attachment") then
local rY = lastPartSize.Y/2
if attachment.CFrame.Y < 0 then
rY = -rY
end
local offY = rY - attachment.CFrame.Y
local scale = Vector3.new(scaleFactor.X,0,scaleFactor.Z)
local offset = Vector3.new(0,((rY*scaleFactor.Y) - offY),0)
if attachment:FindFirstChild("OriginalPosition") then
attachment.OriginalPosition.Value = attachment.OriginalPosition.Value * scale + offset
end
attachment.Position = attachment.Position * scale + offset
end
end
local joint = part:FindFirstChildOfClass("Motor6D")
local a0,a1 = unpack(components[joint.Name] or {})
if not a0 or not a1 then
print(joint,a0,a1,"missing")
return
end
joint.C0 = a0.CFrame
joint.C1 = a1.CFrame