R15 resizing / Objects

If you want to make all parts in a model grow in size continuously, you have to start with a base, and multiply each part’s displacement from the base by whatever factor the model is growing by.

function resizeModel(model, a)
	local base = model.PrimaryPart
	for _, part in pairs(model:GetDescendants()) do
		if part:IsA("BasePart") then
			part.Position = base.Position:Lerp(part.Position, a)
			part.Size *= a
		end
	end
end

Note: you might have to reweld parts together.

function for tweening the model’s size:

local TweenService = game:GetService("TweenService")

local function tweenModelSize(model, duration, factor, easingStyle, easingDirection)
	local s = factor - 1
	local i = 0
	local oldAlpha = 0
	while i < 1 do
		local dt = task.wait()
		i = math.min(i + dt/duration, 1)
		local alpha = TweenService:GetValue(i, easingStyle, easingDirection)
		resizeModel(model, (alpha*s + 1)/(oldAlpha*s + 1))
		oldAlpha = alpha
	end
end

If you want to convert from scale to studs, divide your preferred length for a size property in your model by the current length, and use that for the scale.

33 Likes