I have this module that is great for scaling models:
module.Use = function(model,scale,offset,tweendelay)
local function tweenit(obj,props)
local tw = game:GetService("TweenService")
local twinfo = TweenInfo.new(tweendelay,Enum.EasingStyle.Sine)
local t = tw:Create(obj,twinfo,props)
t:Play()
end
local primary = model.PrimaryPart
local primarycfr = primary.CFrame
for _, p in pairs(model:GetDescendants()) do
if p:IsA("BasePart") or p:IsA("MeshPart") or p:IsA("UnionOperation") then
tweenit(p,{Size = p.Size * scale;})
local rot = p.CFrame - p.CFrame.Position
local newcfr = (primarycfr + primarycfr:inverse() * p.Position * scale) * CFrame.new(offset)
tweenit(p,{CFrame = newcfr * rot;})
end
end
return model
end
this works just fine, however I dont like how it’s growth rate gets larger over time. I want to be able to keep growing it a fixed amount over time but Im not the greatest at math.
What increases scale?
Since you are using tweenit(p,{Size = p.Size * scale;}) I’m guessing that scale is increasing in another script and that’s where you need to troubleshoot.
That function scales in X, Y and Z in the same proportion, so if you want it to scale to a fixed size you must choose one of these dimensions:
For example: if your model is 1x2x3 (XxYxZ) and you want to set the height (Y) to 10 sluds, then X and Z will automatically scale to 5 and 15 respectively.
That said, all you have to do is choose a dimension (X, Y or Z) and use the GetExtentsSize method of Model.
local targetY = 10 -- in this case we choose the height
local scale = targetY/script.Parent:GetExtentsSize().Y -- we find the scale from the heights
module.Use(script.Parent, scale, Vector3.new(0,1,0), 0.25)
this definitely scales it a fixed amount. quick question though, once it scales to the fixed size it will stay there unless I change the fixed number. how would I keep it growing by 10 each time it loops?