Growing a model with a fixed number instead of a scaled number

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.

any help is appreciated.

1 Like

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.

I just have this requiring the module:

while true do
wait(1) 
local module = require(script.Parent.Gradual)
module.Use(script.Parent,1.1,Vector3.new(0,1,0),0.25)
end

each time it gets bigger it scales it by 10% of its current size. im looking to only scale it a fixed amount regardless of its current size.

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)
1 Like

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?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.