How to block a part from appearing if there is another part in its way?

Hello again! I’m trying to make a looping system for something I’m making, and I got stuck on trying to block parts from appearing if there is a part at where its supposed to appear. Is there any type of event or something that could help? Any help is appreciated, thanks!

You can use the built in FindPartsInPart or similar functions, or create your own system for keeping track of what parts are where

2 Likes

You can do this in two ways:

  1. WorldRoot:GetPartsInBox() is great for primitive shapes (specifically boxes).
  2. WorldRoot:GetPartsInPart(), this does however require you to parent the newpart to the workspace. You can use OverlapParams to only check for the part your adding to make it more efficient. To do this you would parent the newPart to workspace, call this function and if the GetPartsInPart() doesn’t return an empty table, destroy the new part.
1 Like

SOLUTION

You need to use a looping system for that.

for i, v in pairs(workspace:GetChildren()) do if v.Name == “Part” and v.BrickColor == BrickColor.new(“brick”) then v:Destroy() end end

Any parts named “Part” with the brickcolor “Brick” will be destroyed.

1 Like

What does brick color got to do with this? Also, Don’t check for parts named Part since they could be renamed. Check their ClassName instead.

1 Like