Scale Multiple Parts Together

My group has 3 parts:

  • Apple (Part)
    in Apple is 2 more parts

I am trying to find a way to scale the 2 inside parts and still keep the position. When I change the size of both, the positioning of those 2 inner parts gets messed up

Screen Shot 2022-10-13 at 4.06.52 PM
Screen Shot 2022-10-13 at 4.07.18 PM

Clarification
Using the Roblox Studio scale tool works. I am trying to do this in a script

I think if you hold shift while changing the size, it should work fine.

1 Like

There are Plugins that help scale. I think one of them is called ScaleLite or soemthing

1 Like

Using the Roblox Studio scale tool works. I am trying to do this in a script cc @incognitobot_rblx

1 Like

This will help

I tried that and for some reason does not work, positioning is still messed up

1 Like

If you want the part to stick at the top, for example, you would have to move it up by half the change in size in the y axis:

part.Size = Vector3.new(1,1,1)
part.Size = Vector3.new(1,3,1) -- change in size in the y axis = 2
part.Position += Vector3.new(0,1,0) -- half of that

This makes the example part 2 studs bigger in the y axis and moves it up 1 stud, keeping it on the surface of whatever it was on.

It works when sizing down too, except you move it down instead of up

These all have the same format, (2 parts, 1 is above the other) but for some of them it doesn’t position properly

It probably has something to do with the rotation of the parts. Try to see which axis is “up” and move it using:

part.Position = part.CFrame:PointToWorldSpace(move it using the correct axis)

None of the parts have any rotation

Then sorry, but I dont know how to help, if all parts have exactly no rotation, it should work fine.

Edit: Maybe if you could show what it looks like after it runs (and the code too) i could try to come up with a solution

Screen Shot 2022-10-13 at 4.42.29 PM

It looks like they are being moved up too much.
Remember that, the amount it is moved by is half the change in size in the y axis:

local change = newY-prevY
part.Position += Vector3.new(0,change/2,0)

If this is not it, then I cant do anything else without looking at the script.

This is the code I used, “default” is the stem part

local function scaleFruit(fruit, scale)
	local default = fruit:FindFirstChild("default")
	local base = fruit:FindFirstChild("base")
	if not base or not default then return end
	
	local previousSize = default.Size
	local newSize
	
	default.Size = default.Size * scale
	base.Size = base.Size * scale
	newSize = default.Size
	
	default.Position += Vector3.new(0, (newSize.Y - previousSize.Y) / 2, 0)
end

Youre scaling the base too, so you need to move it down, or add half the change in size to the base:

default.Position += Vector3.new(0, (newSize.Y - previousSize.Y) / 2, 0)
base.Position -= Vector3.new(0,(newBaseSize.Y - prevBaseSize.Y)/2,0)

or

default.Position += Vector3.new(0, (newSize.Y - previousSize.Y + newBaseSize.Y - prevBaseSize.Y) / 2, 0)

default.Position += Vector3.new(0, newSize.Y - previousSize.Y + newBaseSize.Y - prevBaseSize.Y, 0)

Sorry, i believe something else is causing the issue, I tested the function myself and it worked flawlessly:
Original:
image
Scaled up:
image

can you show me the hiercahy in explorer

Sure thing.
image

So the difference here is that the parent is a part, not a model and the base and default parts have weldconstraints to the parent part