Dear scripters, as we know from the basics, we can change a part's size by changing the size
property. Let's say I have
part.Size = Vector3.new(10,2,5)
then,
part.Size = Vector3.new(20,2,5)
will elongate my part by 10 units on the X dimension.
The problem with this approach is that the part's position
will also change and will be out of alignment with the old one. How can one change the size
, for example elongating/stretching a brick, while maintaining alignment?
Here is a pic in order to make my point clearer visually: https://imgur.com/a/SaRS7Ty
Of course, I am here as I am looking for a programmatic solution; this is an easy task using the studio interface.
This could get a bit complicated. I'm not the best programmer and have not tested this but you could try:
Xgrow = 10 Ygrow = 0 Zgrow = 0 part = workspace.Part --saves Position PartPositionX = part.Position.X PartPositionY = part.Position.Y PartPositionZ = part.Position.Z --saves size PartSizeX = part.Size.X PartSizeY = part.Size.Y PartSizeZ = part.Size.Z part.Size = Vector3.new(PartSizeX + Xgrow,PartSizeY + Ygrow,PartSizeZ + Zgrow) RepositionX = Xgrow / 2 RepositionY = Ygrow / 2 RepositionZ = Zgrow / 2 part.Position = Vector3.New(PartPositionX + RepositionX, PartPositionY + RepositionY, PartPositionZ + RepositionZ)
This will let you grow parts by changing Xgrow, Ygrow, and Zgrow. Kind of like studio. Tell me if this doesn't work right. As I said I didn't test it