Ok so got these three parts, so they will be placed in a map. if they are touching something they have to be repositioned, but the problem is I want it to be effectively repositioned not randomly. So for example, not going out of the map.
You can do math.random() for the x,z axis(if the ground is flat) and set the parameters for it to whatever your baseplate’s length and width are. If you don’t want it being random at all, you can set up little nodes and put those in a folder, then loop through that.
If your map does not have any overhangs or overlapping terrain, you could generate a random x and z coordinate high above the map (y=500 or so) and raycast downwards to find the proper position for your part.
local DOWN_DIRECTION = Vector3.new(0,-500,0); --Should be long enough to hit the ground
local x,y,z = math.random(-100,100),500,math.random(-100,100);
local _,position,_ = workspace:FindPartOnRay(Ray.new(Vector3.new(x,y,z),DOWN_DIRECTION)); --Part hit, point of intersection, and surface normal
part.Position = position;