If something is in the way when I resize something a brick via script, the resized brick moves to the top of any object it collided with, I want it to resize without it moving whenever it hits something, any idea how I would do that?
Script I'm using currently
Part.Size=Part.Size+Vector3.new(0,-1,0)
Well, I am not sure what's the right way to do it, but here is what came first to my mind:
You can store previous CFrame
and then bring the Part
back to it.
Though, when resizing, it will still move because if you resize only 1 side, CFrame
will center it again, making it move by half of the Vector3
difference between start and end Size
.
To correct this, you can subtract half of that Vector3
from the starting CFrame
.
local prevPos = Part.CFrame Part.Size = Part.Size + Vector3.new(0, -1, 0) Part.CFrame = prevPos - Vector3.new(0, -0.5, 0)
I am not sure if that is what you wanted, so make sure to comment if you need any more help.
Edit
I just realized that this is almost certainly not what you wanted.
What the above code does, is it moves the Part
away from the face that is being resized (which might be useful for some occasions), so you can keep the parts connected at that face.
What I think you really want to do is just make the Part
go inside the other Part
.
To do this, just change the Vector3
subtraction to addition:
local prevPos = Part.CFrame Part.Size = Part.Size + Vector3.new(0, -1, 0) Part.CFrame = prevPos + Vector3.new(0, -0.5, 0)