I’m making a simple grid system but for some reason when I try to put a block on the side -X it gets inside the other block as well when I try to put it on the bottom
This is my code:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = game.Workspace.Camera
local Size = 2
local Grid = 2
mouse.Button1Down:Connect(function()
local MouseOn = mouse.Target
local Block = Instance.new("Part", game.Workspace)
Block.Size = Vector3.new(Size, Size, Size)
Block.Color = Color3.new(Random.new():NextNumber(0, 1), Random.new():NextNumber(0, 1), Random.new():NextNumber(0, 1))
Block.Anchored = true
local PosX = math.floor(mouse.Hit.Position.X/Grid + 0.5) * Grid
local PosY = math.floor(mouse.Hit.Position.Y/Grid + 0.5) * Grid
local PosZ = math.floor(mouse.Hit.Position.Z/Grid + 0.5) * Grid
Block.Position = Vector3.new(PosX, PosY, PosZ)
end)