Okay, so i have a script which highlights a block when you move and when you click it places the block.
It works just fine, but it only seems to work on 2 of the 4 sides of the square. The other two sides snap to the top of the block, but the other sides place blocks on the side easily. Here's my code.
grid = game.Workspace.Garage.Grid
player = game.Players.LocalPlayer
tag = Instance.new("StringValue")
tag.Name = "block"
local mouse = player:GetMouse()
prevBlock = nil
mouse.Move:connect(function()
if prevBlock ~= nil then
prevBlock:Destroy()
prevBlock = nil
end
if mouse.Target ~= grid and not mouse.Target:FindFirstChild("block") then
return
end
blockPrev = Instance.new("Part", workspace)
blockPrev.BrickColor = BrickColor.new("Bright green")
blockPrev.Anchored = true
prevBlock = blockPrev
blockPrev.Size = Vector3.new(1,1,1)
local pos = mouse.hit.p
blockPrev.Position = Vector3.new(math.floor(pos.X)+.5,math.floor(pos.Y)+.5,math.floor(pos.Z)+.5)
end)
mouse.Button1Down:connect(function()
local block = Instance.new("Part", workspace)
block.Anchored = true
tag:Clone().Parent = block
local placePos = blockPrev.Position
blockPrev:Destroy()
block.Size = Vector3.new(1,1,1)
block.Position = placePos
end)

2 comments
Perhaps try adjusting to use CFrame instead of Position.
That didn't work, it now places the blocks inside of the block instead of on top.