4X4X4 building system, Block CFrame position manipulation

Hello
so, i have made building system, now i have to manipulate block CFrames a bit…
There is original position that gets changed, calculated if there are 2 parts touching, if they are, i need to move new block by 1 studs away from other block


but orientation makes it bit hard to do…

i need to make it always to move like this

1 Like

Do you have any code we can work from?

2 Likes

server

game.ReplicatedStorage.Place.OnServerEvent:Connect(function(p,RX,RY,RZ,ItemR)	
	if game.ReplicatedStorage:FindFirstChild(ItemR)~= nil then
	item=game.ReplicatedStorage:FindFirstChild(ItemR):Clone()
	item.Parent=workspace
				item:SetPrimaryPartCFrame(CFrame.new()+Vector3.new(RX,RY,RZ))
				game.ReplicatedStorage.RemoveItemE:FireClient(p,ItemR,true)
			 end

end)

clinet:

local RX=shifter.GetShiftedValue(mouse.hit.X)
			local RY=shifter.GetShiftedValue(mouse.hit.Y)
			local RZ=shifter.GetShiftedValue(mouse.hit.Z)

			if (Vector3.new(RX,RY,RZ)-mouse.Target.Parent.CENTER.Position).magnitude <4 then
				
			else
				game.ReplicatedStorage.Place:FireServer(RX,RY,RZ,Hand)
			script.Parent.LocalSEvents.InventoryRemove:Fire(weaponIndex,false)
end
		end
		
	end
end