So anyways
I need to scale models using attributes
which will be a vector3 value
these are the same 2 models with different vector3 values in size for the attribute
how would i properly scale them without using anything else like an iv loop to make them the same size of each part
For example if a model is 10 ,10,10
and another model i want to scale to is 50,50,50
I want the model to become from 10,10,10 to 50,50,50
while still maintaining the scale of all the parts in the model
I tried dividing 50/5 and using the value of 5 to multiply the size of 50,50,50 to every single part
now the problem is that since i do this to every part it ends up becoming bigger
does anyone know how I can get this to work?
Good news for you, Roblox just announced that they will add a new Model:ScaleTo()
function 8 days ago from this post.
1 | local size = 10 |
2 | Model:ScaleTo(size) |
However, Roblox hasn't officially released it yet as it is still pending (from this page). Be patient until it goes live.
In the meantime, try this code that I got from this guy. (credits btw)
01 | function ScaleModel(model, xScale, yScale, zScale) |
02 | local cf, _ = model:GetBoundingBox() |
03 | local origin = cf.Position |
04 |
05 | local scale = Vector 3. new(xScale, yScale, zScale) |
06 |
07 | for _, obj in pairs (model:GetDescendants()) do |
08 | local OriginalSize = obj:GetAttribute( "OriginalSize" ) |
09 | if OriginalSize = = nil then |
10 | if obj:IsA( "BasePart" ) then |
11 | obj:GetAttribute( "OriginalSize" , obj.Size) |
12 | elseif obj:IsA( "JointInstance" ) then |
13 | obj:GetAttribute( "OriginalSize" , Vector.zero) |
14 | elseif obj:IsA( "SpecialMesh" ) then |
15 | obj:GetAttribute( "OriginalSize" , obj.Scale) |