the first thing i show is what i have (here is the script)
wait(3)
while true do
wait(0.15)
for _,v in pairs(script.Parent:GetDescendants()) do
if v:IsA("BasePart") then
v.Size = Vector3.new(v.Size.X - 0.1,v.Size.Y - 0.1,v.Size.Z - 0.1)
end
end
end
and the 2nd thing i show is what i want to achieve where it all stays together
I’m thinking you will want to make a single union that includes the larger stone and the ore pieces. Then you should look into tweening the size instead of using the loop.
If you’re set on using a loop and keeping the parts separate, your issue seems to be that you’re subtracting a fixed measurement from both the rock and the ore pieces. 0.1 is a small percentage of the size of the boulder, but a large % of the size of the ore pieces. You may be able to apply a factor (i.e. divide by a % of each measurement) instead of subtracting a fixed amount.
Alternatively, you could resize the multiple parts using a different method.
The scale would still be decreased linearly for each object, however you would also have to define an origin point for the scale transformation to reposition the parts. For a model, this could easily be the primary part’s position.
Then you would just reposition the part by scaling the vector between the origin and the parts position by a specific amount.
Examples:
local function scaleModel(model, scaleFactor, origin)
origin = origin or model.PrimaryPart.Position
for _, p in ipairs(model:GetDescendants()) do
if p:IsA("BasePart") then
local position = (p.Position - origin) * scaleFactor
local size = p.Size * scaleFactor
-- repositions the part using cframe without modifying the rotation
p.CFrame = p.CFrame - p.CFrame.Position + position
p.Size = size
end
end
end
With the function I posted, if you were to scale it in a loop, you would get an exponential decay of size which might not be desired. If that is the case, I suggest storing the relative offsets in a table and then referencing those to do a linear resizing.
wait(3)
local Primary = script.Parent.PrimaryPart
while true do
wait(0.15)
for _,v in pairs(script.Parent:GetDescendants()) do
if v:IsA("BasePart") then
v.Size -= v.Size/10
v.Position -= (Primary.Position - v.Position).unit/10
end
end
end
The position wont be accurate since i should use cframe but currently i gtg