Help with wall placing system

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to fix my issue with my walls placing inside of each other and have it so no walls can be placed inside of other walls.

  1. What is the issue? Include screenshots / videos if possible!

Some walls will be able to be placed inside of at all times and the players and other players walls can be placed inside of at sometimes, like when you have high ping or out of nowhere causing the game to be not fun and weird to play.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried changing how the wall is detected a few times but nothing seems to work.

local function GetTouchingParts(Part)
	local Connection = Part.Touched:Connect(function() end)
	local Results = Part:GetTouchingParts()
	Connection:Disconnect()
	return Results
end

local Results = GetTouchingParts(BuildMesh)
		local Placeable = true
--METHOD 1

		--for _, Build in pairs(Results) do
		--	if Build.Name == BuildMesh.Name then
		--		if Build.Position == BuildMesh.Position then
		--			Placeable = false
		--		end
		--	end
		--end
--METHOD 2

		for _,v in pairs(Results) do
			if v.Name == "Wall" then
				print("wall1")
				local vector = Vector3.new(v.Position.X,v.Position.Y,v.Position.Z)
				if v.Position.X ~= BuildMesh.Position.X and v.Position.Z == BuildMesh.Position.Z then
					vector = Vector3.new(BuildMesh.Position.X,vector.Y,vector.Z)
				elseif v.Position.Z ~= BuildMesh.Position.Z and v.Position.X == BuildMesh.Position.X then
					vector = Vector3.new(vector.X,vector.Y,BuildMesh.Position.Z)				
				end
				if vector == BuildMesh.Position then
					print("wall2")
					Placeable = false
				end
			end
		end
		if(Placeable) then
			PlaceBuildEvent:FireServer(BuildName, BuildMesh.Position, BuildMesh.Orientation)
		end

Thanks if you can help, if you need anything else to help me I’ll send it.

For this you can use the method of workspace get part bounds in box. And if you detect any parts just loop through the table returned and see if it detected a wall then make it non placeable. WorldRoot | Documentation - Roblox Creator Hub

I will try this, however this is basically what I am already doing except I just check what parts are touching the “buildRoot” and then check the name of the wall and position to see if its inside of something as it runs on a grid.

Suggestion: Raycast in the direction the player wants to build, if it returns a part, then there is probably something already built there.

I take what I said back, this works perfectly after adjusting the size input. Thanks for the help!