function scaleModelWithJoints(model, scale)
local origin = model.PrimaryPart.Position
for _, obj in ipairs(model:GetDescendants()) do
if obj:IsA("BasePart") then
obj.Size = obj.Size*scale
local distance = (obj.Position - model:GetPrimaryPartCFrame().p)
local rotation = (obj.CFrame - obj.Position)
obj.CFrame = (CFrame.new(model:GetPrimaryPartCFrame().p + distance*scale) * rotation)
elseif obj:IsA("JointInstance") then
local c0NewPos = obj.C0.p*scale
local c0RotX, c0RotY, c0RotZ = obj.C0:ToEulerAnglesXYZ()
local c1NewPos = obj.C1.p*scale
local c1RotX, c1RotY, c1RotZ = obj.C1:ToEulerAnglesXYZ()
obj.C0 = CFrame.new(c0NewPos)*CFrame.Angles(c0RotX, c0RotY, c0RotZ)
obj.C1 = CFrame.new(c1NewPos)*CFrame.Angles(c1RotX, c1RotY, c1RotZ)
elseif obj:IsA("HingeConstraint") then
obj.Attachment0
obj.Attachment1
local c0NewPos = obj.C0.p*scale
local c0RotX, c0RotY, c0RotZ = obj.C0:ToEulerAnglesXYZ()
local c1NewPos = obj.C1.p*scale
local c1RotX, c1RotY, c1RotZ = obj.C1:ToEulerAnglesXYZ()
obj.C0 = CFrame.new(c0NewPos)*CFrame.Angles(c0RotX, c0RotY, c0RotZ)
obj.C1 = CFrame.new(c1NewPos)*CFrame.Angles(c1RotX, c1RotY, c1RotZ)
end
end
end
I want the code to resize the hingeconstraints too based on the attachment 1 and attachment 0 if anyone can help please