You can write your topic however you want, but you need to answer these questions:
- 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.
- 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.
- 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.