I am making a sandbox building game, however I have encountered a problem. When I built, the parts clip through each other. See screenshot to see what I mean. https://imgur.com/a/zajPc1S
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local backpack = localPlayer:WaitForChild("Backpack")
local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.CanBeDropped = false
tool.Parent = backpack
tool.Name = "Part"
function round(n)
return math.floor(n + 0.5)
end
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Parent then
local part = Instance.new("Part", workspace)
part.Size = Vector3.new(2,2,2)
part.Position = mouse.Hit.p
part.Anchored = true
local x = part.Position.x
local y = part.Position.y
local z = part.Position.z
part.Position = Vector3.new(round(x),round(y),round(z))
end
end)
end)
