I can't seem to resize models correctly

I am trying to make a tool, that makes objects smaller, which its doing what its supposed to do so far, except for the fact everything loses its rotation and original position.

Here is what’s happening:
https://gyazo.com/c98e8925ec3aca3771495c2ff3e16839

I have tried searching the internet on how to resize models with scripts, and found a thread on dev forums which shows how to do so, everything works in that script except the rotation gets messed up.

function ConstructionTool:CreateLoop(PlayerTable)
	--Destroy welds
	for _,object in pairs(PlayerTable.Item:GetDescendants()) do
		if object:IsA('Weld') or object:IsA('ManualWeld') or object:IsA('WeldConstraint') then
			object.Part0.Anchored = true
			object.Part1.Anchored = true
			object:Destroy()		
		elseif object:IsA("CFrameValue") then
			object:Destroy()
		end		
	end
	
	-- resizing [MAIN]
	return RunService.Heartbeat:Connect(function()
		--Scale BaseParts
		for _,object in pairs(PlayerTable.Item:GetDescendants()) do
			if object:IsA('BasePart') then	
				object.Size = object.Size*0.999

				local distance = (object.Position - PlayerTable.Item.PrimaryPart.CFrame.p)
				local rotation = (object.CFrame - object.Position)
				object.CFrame = (CFrame.new(PlayerTable.Item.PrimaryPart.CFrame.p + distance*0.999) * rotation)
			end
		end
	end)
end

I might be missing something, but have you tried doing just local rotation = object.Orientation?

I am multiplying rotation with cframe, I can’t multiply vector3 with cframe.

Oh yeah, that’s true, maybe using CFrame.Angles(object.Orientation.X, object.Orientation.Y, object.Orientation.Z) would be a good way to keep the Rotation?

I am pretty sure thats the same thing, plus I would have to use math.rad, which I think will be a big pain, but I will go give it a try. I am like 70% sure that Cframe - position is the same.

Yea I just tried it, and its literly the same thing.

1 Like

Have you tried doing it like this?

local oldSize = object.Size
local newSize = oldSize*0.999
object.Size = newSize
object.Position = object.Position - Vector3.new(0, (oldSize.Y - newSize.Y) / 2, 0)

I have tried scaling parts in studio using the default scaling tool while holding shift and found out that this might work well.

EDIT:
It works well on single part when executed from command line. https://gyazo.com/4d2c7eddb9824039823aebcabb602ca0

Doesn’t seem to work on a model, with meshes and parts.

I recommend using TweenService. Because TweenService consume less resources and make the code easier to read.

I hope you realize what you are saying, is not related to my topic at all, you are asking me to use tween service when I am asking how to resize model, not parts.

Bruh. You are haven’t seen my post?

TweenService can also resize parts and Tween models.

hmm okay, I am currently reading the post.