I'm making a build tool that creates parts wherever you click in the world. Thes script makes the parts do not pass trough each other, but, sometimes,if you put a part between two parts that are so together the part will pass through the other parts and i'd like to know how to make a placement grid to make the parts line up.
Here's a picture to help you understand my problem.
Here's the scripts.
-- Local script in the tool
local Event = game:GetService("ReplicatedStorage"):WaitForChild("PartsFromTool")
local equipped = false
script.Parent.Equipped:Connect(function(mouse)
equipped = true
game:GetService("UserInputService").InputBegan:Connect(function(input, g)
if (equipped == true) then
if (input.UserInputType == Enum.UserInputType.MouseButton1) then
local position = mouse.Hit
Event:FireServer(position)
end
end
end)
end)
script.Parent.Unequipped:Connect(function()
equipped = false
end)
-- Server Script in ServerScriptService
game:GetService("ReplicatedStorage"):WaitForChild("PartsFromTool").OnServerEvent:Connect(function(player, position)
local PCreated = Instance.new("Part")
PCreated.Parent = game.Workspace
PCreated.Size = Vector3.new(3, 3, 3)
PCreated.Material = "Brick"
PCreated.BrickColor = BrickColor.new("Persimmon")
PCreated.CFrame = CFrame.new(position.Position) * CFrame.Angles(0, 0, 0)
wait(0.001)
PCreated.Anchored = true
PCreated.CFrame = CFrame.new(PCreated.Position) * CFrame.Angles(0, 0, 0)
end)

4 comments
So you want to snap the parts to a grid so you can't place a part inside another part? Also the link just brings me to a blank page.
Yes, i want that, and here's another link: https://image.ibb.co/mJ8XvU/Captura.png
I have found something that really helped me, make sure to check this! "https://web.roblox.com/games/1095570774/Placement-System-Example"
Answered!