# Setting an objects size on the x axis 'relative' to a positions x axis

I don’t believe I was able to summarize the issue properly on the title, so I apologize for that, however here’s a little more descriptive explanation with photos.

So I have this part here, and im attempting to change the size on the x axis to the black parts position, also on the x axis.

The finished result would look like this:

I was able to make it work with the y axis with the following code:

``````local size = Vector3.new(bottom.Size.X, pos.Y, bottom.Size.Z)
local position = Vector3.new(bottom.Position.X, size.Y / 2, bottom.Position.Z)
``````

But I’m unsure how to make it work on the x axis. If anybody is willing to help, that would be greatly appreciated.

So you’re trying to make his x size into his x position? Not quite understanding what you want, but if thats it, you can do

``````local position = Vector3.new(size.X, size.Y / 2, bottom.Position.Z)
``````

No, maybe I didn’t explain it correctly.

Here’s a video demonstrating how it would work (the black part is the target x)

oh i see what you mean now. There are 2 ways of doing this. The thing is, if you resize the part, it resizes from both sides, so it would not be like in the video with a simple code, so what i recommend doing, is changing black parts position, rather than resizing white part

``````blackPart.Position = Vector3.new(whitePart.Size.X/2, --whatever Y you want, whatever Z you want)
``````

This would move the black part to the edge of the white part. Note that the black part has to be a child of the white part, so that it moves relative to it.

If this solution doesnt suit you, doing the other way would be much harder and unnecessarily complicated, but we can still work it out.