So I was trying to make a placement system with a grid and It kind of worked but I have this problem;
I can only place blocks on a certain side of other blocks.
I can’t really explain it but this is what I mean:
So the black square is the block that has already been placed, the green squares is the place where I can place blocks, but the red is where I cannot place blocks.
I don’t want this to happen.
Here is the script(It is all done on client side):
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Tool = script.Parent
local ToolEquiped = false
function round(number, to)
return math.floor((number / to) + 0.5) * to
end
local TestPart = Instance.new("Part")
TestPart.Parent = workspace
TestPart.Size = Vector3.new(5,5,5)
TestPart.BrickColor = BrickColor.new("Institutional white")
TestPart.Transparency = 0.5
TestPart.CanCollide = false
TestPart.Anchored = true
Mouse.TargetFilter = TestPart
Tool.Equipped:Connect(function()
ToolEquiped = true
while ToolEquiped == true do
TestPart.Position = Vector3.new(round(Mouse.hit.p.X, 5),round(Mouse.hit.p.Y, 5) , round(Mouse.hit.p.Z, 5))
wait()
end
end)
Tool.Unequipped:Connect(function()
ToolEquiped = false
end)
Tool.Activated:Connect(function()
local Block = TestPart:Clone()
Block.Parent = workspace
Block.CanCollide = true
Block.Transparency = 0
end)
Here is a link to the game so that you can see what I mean(There are still other things that I need to fix):