Tweening Model Size?


Still needing help on this.

I’m looking for a way of utilising ModelSize tweening -

Brief summary - Working on a space game that features “Light speed” and I want the Planets / Space stations to enlarge when the Players ship arrives at their destination.



Ideally, I’m looking for it to tween between two sizes - The required size of the actual Model (visible) and Vector3.new(0.05, 0.05, 0.05) (Not visible)

However, I’ve come across a Function that allows me to use increments.

local i = 0
	local oldAlpha = 0
	while i < 1 do
		local dt = RunService.Heartbeat: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

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

wait(5)

tweenModelSize(game:GetService("Workspace"):WaitForChild("Planet"), .25, 2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)

Would it be possible to add a value inside of the model to Rescale and adjust it accordingly - Going to warp reduces it to -1 then exiting would re increase it by the scale it went down?

Thoughts?

1 Like