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
    local relative = pos - target.Position
    if relative.y + (target.Size.y / 2) > target.Size.y - .1 then
        preview.CFrame = preview.CFrame + Vector3.new(0,(preview.Size.y / 2),0)
    end
    if relative.y - (target.Size.y / 2) < (target.Size.y * -1) + .1 then
        preview.CFrame = preview.CFrame - Vector3.new(0,(preview.Size.y / 2),0)
    end

    if relative.x + (target.Size.x / 2) > target.Size.x - .1 then
        preview.CFrame = preview.CFrame + Vector3.new((preview.Size.x / 2),0,0)
    end
    if relative.x - (target.Size.x / 2) < (target.Size.x * -1) + .1 then
        preview.CFrame = preview.CFrame - Vector3.new((preview.Size.x / 2),0,0)
    end

    if relative.z + (target.Size.z / 2) > target.Size.z - .1 then
        preview.CFrame = preview.CFrame + Vector3.new(0,0,(preview.Size.x / 2))
    end
    if relative.z - (target.Size.z / 2) < (target.Size.z * -1) + .1 then
        preview.CFrame = preview.CFrame - Vector3.new(0,0,(preview.Size.x / 2))
    end

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