Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

	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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.