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

Create a clone of a part with default orientation but the same size/position?

Asked by
Abandion 118
5 years ago
Edited 5 years ago
01local relative = pos - target.Position
02if relative.y + (target.Size.y / 2) > target.Size.y - .1 then
03    preview.CFrame = preview.CFrame + Vector3.new(0,(preview.Size.y / 2),0)
04end
05if relative.y - (target.Size.y / 2) < (target.Size.y * -1) + .1 then
06    preview.CFrame = preview.CFrame - Vector3.new(0,(preview.Size.y / 2),0)
07end
08 
09if relative.x + (target.Size.x / 2) > target.Size.x - .1 then
10    preview.CFrame = preview.CFrame + Vector3.new((preview.Size.x / 2),0,0)
11end
12if relative.x - (target.Size.x / 2) < (target.Size.x * -1) + .1 then
13    preview.CFrame = preview.CFrame - Vector3.new((preview.Size.x / 2),0,0)
14end
15 
View all 21 lines...

Script that will move a part and move it so that it doesn't clip through mouse.target. Problem here is that size doesn't change with orientation, so anything but the default will have the part offset.

1 answer

Log in to vote
0
Answered by
Abandion 118
5 years ago

Had to write a script to swap the x and z values if the lookvector.z was greater than -1.

Ad

Answer this question