Resizing Model [ via Tween? ]

I’m working on a Space - Exploration game and am looking for ways to Tween the size of a Model.

Why?
The game will feature ‘Hyper-space’ and I’m looking to make Planets “grow” when arriving at the destination; giving off the illusion they’ve come into range.

I know I can simply :Tween a single Part to grow to the required size, however - I’m looking to do this for a model; that way the Atmosphere surrounding the core retains the same increments etc.

I’m looking at @Crazyman42 resize script:
Though, instead of using * to determine an increment, I wish to have it as two points -

  1. Not in range (Shrunk and not visible. I.E. vector3.new(.05, .05, .05))
  2. in-range (Planets actual size. I.E. Value within Planet: vector3.new(100, 100, 100))

function ScaleModel(model, scale)
	local primary = model.PrimaryPart
	local primaryCf = primary.CFrame
	for _,v in pairs(model:GetDescendants()) do
		if (v:IsA("BasePart")) then
			v.Size = (v.Size * scale)
			if (v ~= primary) then
			v.CFrame = (primaryCf + (primaryCf:inverse() * v.Position * scale))
		end
	end
end
return model
end
ScaleModel(game:GetService("Workspace"):WaitForChild("Planet"), 1)
2 Likes

Update: 1



Found a way of Tweening the sizes of Models; however, how can I adjust this to allow for specific sizes - eg; 100, 100, 100 - as opposed to increments.

local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")

function tweenModelSize(model, duration, increment, easingStyle, easingDirection)
	local s = increment - 1
	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)

bump