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 without it going crazy?

Asked by
SuperFryX 130
8 years ago

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)
0
This is actually useful! unfortunately, I tried and it didn't work :l Codebot 85 — 8y
0
I see a problem, When you use "Part.Size" it does not know the rest of the pattern, it could be game.ServerStorage.Part.Size or workspace.Part VenomiZeD_VamqireXz 111 — 6y

1 answer

Log in to vote
0
Answered by 8 years ago

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)
Ad

Answer this question