Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I resize a part while making it appear to stay in the same spot?

Asked by 5 years ago
Edited 5 years ago

I'm trying to change the size of a part called lock. This is the first code I used:

    lock.Size = lock.Size - Vector3.new(0, 0, 0.25)

This changes the size, but not the position, so the part comes off the wall.

Images: Before | After

I added another line to change the position so the part stays on the wall.

lock.Position = lock.Position - Vector3.new(0.125, 0, 0)

But this only works when the part is facing a certain direction. I'm going to use this code for other parts, and it would be inefficient to have to correct the repositioning of the new part every time.

I decided to use the resize function instead, and this fixes the positioning problem.

lock:Resize("Front", 1)

As seen before though, I am trying to change the size by a decimal, but since the second parameter in the resize function only takes integers, I can't do that.

How do I resize a part while keeping it in the same visual position without having to add repositioning each time? Sorry if this is confusing, I tried my best to explain.

1 answer

Log in to vote
0
Answered by
aazkao 787 Moderation Voter
5 years ago

Whenever you resize a part with code, say you want to resize brick by increasing 1 stud in the X direction, and the bricks position is at (1,1,1) the X position of the brick will change by half of how much you increased the the brick's X value. so if you increase the brick by 1 stud in the X direction, the new brick position will be (1.5,1,1)

So you can try resizing the brick with a value and then change the position of the brick by half of the value, you even did it in your code already, 0.125 is half of 0.25.

As for changing which value of the position(X? Y? or Z?) you will have to do it through trial and error as im not too familiar with roblox 3D positioning

Ad

Answer this question