So I've made a 100x100 part and I'd like to be able to randomly place a part inside of there, I've divided the grid up into 5x5 parts inside of that and I've iterated through the model in workspace that the grid is contained in but whenever I put the parts inside of that grid they're all right next to to each other. I'd like to be able to have them each a certain distance away from each other. How would I achieve this?
Lets use some simple math to make sure they're spread apart from each other.
Our grid is 100x100, so lets assume its in the centre of the map. Our parts are 5x5 each. 100/5 is 20. That means we have 20 possible places for each axis.
The centre of a 5x5 part is 2.5 by 2.5, however the boundaries of the grid are 50,50,-50,-50. This means that the position of the 5x5 part must begin at 47.5, and iterate by 5.
local positionX = math.random(20) --generating a random number from 1 to 20 local positionY = math.random(20) --doing the same for both axis positionX = (positionX-10.5)*5 --converting the random number from 1~20 to -47.5~47.5 positionY = (positionY-10.5)*5 --doing the same for both axis positionVector = Vector3.new(positionX,0,positionY) --creating the vector.
Alternatively this code can be condensed into
positionVector = Vector3.new((math.random(20) -10.5)*5,0,(math.random(20) -10.5)*5)
Hope this is what you were looking for, or at least can build off of what I taught you.