So, I have a building system, and I want to get it to not place in the same position of another. There are collision parts inside all of the models. This is the part I'm having a problem with. It is only doing it for the recent model added to the folder,
for a, b in pairs(placedTiles:GetChildren()) do print("Finding Touched") if b:FindFirstChild("Selection") and (b.Selection.Position - tile.Selection.Position).Magnitude < 0.001 then canBuild = false tile.Selection.SelectionBox.Color3 = Color3.fromRGB(255, 0, 0) tile.Selection.SelectionBox.SurfaceColor3 = Color3.fromRGB(255, 0, 0) tile.SelectionBox.Color = Color3.fromRGB(255, 0, 0) elseif b:FindFirstChild("Selection") and (b.Selection.Position - tile.Selection.Position).Magnitude > 0.001 then canBuild = true tile.Selection.SelectionBox.Color3 = Color3.fromRGB(0, 255, 0) tile.Selection.SelectionBox.SurfaceColor3 = Color3.fromRGB(0, 255, 0) tile.SelectionBox.Color = Color3.fromRGB(0, 255, 0) end end
Any help would be grateful :D
Edit: It only checks for the most recent child added to the folder, as of printing the magnitude.
Edit 2: I tried it with tables and the same thing is happening.
I found a way to do it. I use table.find to check if the position is inside a position found in the table.