I was wondering how I would spawn a brick in a certain range, but ignore parts and other debris already spawn/placed there. Kind of like this;
RED = Do NOT Spawn
BLUE = Spawn range

I was wondering how I would spawn a brick in a certain range, but ignore parts and other debris already spawn/placed there. Kind of like this;
RED = Do NOT Spawn
BLUE = Spawn range

You can create a random position and repeat it until it is not within the bounds of any of the red parts.
Consider the use of GetPartsInPart
The simplest solution I can think of is querying for possible positions for the new item to spawn, by specifying the area items can spawn, and then constructing a new bounding box at some given coordinates on the plane where items can spawn, then executing a check to see if that bounding box collides with another item that already spawned, and continuing to do this until space is found.
This is the simplest thing I could think of. It avoids using repeated magnitude checks and also having to execute those checks on every single item that spawns in.
Here’s the method I was thinking of:
https://developer.roblox.com/en-us/api-reference/function/WorldRoot/GetPartBoundsInBox
You can create a part to act as the grid of where items can spawn, and then calculate random positions within it. Finally, check to see if any parts are within the calculated position, and if so, repeat the process until empty space is found.
Could you possibly show me a script as to how it would work, I don’t know how to detect if it overlaps another position.
EDIT: I think I figured it out