How should I go about making a grid for this?

Heyo, I’m making a World-Simulation type game, and I want to figure out how I should make a grid for my map.

I will be using this grid for placing down random tree’s in grid areas, placing down Homes and other objects in Grid Areas (Including but not limited to 4 or more grid parts)

I want this gride to be built up with an 82 yolow part for each layer of the grid, and I want it to cover up 512 studs (64 82 parts)

How should I go about making this?

Generate a 2-dimensional array, and then clone a model to the world for each item in the 2d array.

You will need to save your models to ReplicatedStorage, clone them, and move them to a position in the world. There is some math involved with this, here is an example function:

-- This function takes an x and y coordinate for the map and returns a Vector3 position.
function GetOffsetPosition(x, y)
	local blockWidth = 50
	local studWidth = 600
	local studHeight = 600
	return Vector3.new(x * blockWidth - studWidth/2 - blockWidth/2, blockWidth/2, y * blockWidth - studHeight/2 - blockWidth/2)
end

I recommend that you use a base model and edit that model in code to place your houses, trees, etc. then clone the model to your map location.

Is it possible that you can explain the math? I haven’t done this before, therefore, I’m confused.

Also, how would I create a 2-dimensional array?

This strategy works for a square map, filled with square models. You can create a some preset models that are all the same size, and place these models in your world based on the 2d array that you generate.

A 2-dimensional array is just an array of arrays. It will look something like this:

local map_layout = {
    {"grass", "forest", "forest"},
    {"grass", "forest", "forest"},
    {"forest", "forest", "forest"},
}

Each item on the grid will have an ‘x’ and ‘y’ position. For example, the item in the top left corner of this 3x3 grid would be at position (1,3).

The GetOffsetPosition function will return a Vector3 for an ‘x’ and ‘y’ coordinate on your map.

Assuming your map is square, and each model in your map is square, you can use this function to get the world position to place each model in your map.

-- This function takes an x and y coordinate for the map and returns a Vector3 position.
-- blockWidth is the width/height in studs of each model.  All models should be the same size.
-- numBlocksXY is the width/height of your map, if your map is 8x8 this number will be 8.
function GetOffsetPosition(x, y, numBlocksXY, blockWidth)
	local studWidth = numBlocksXY * blockWidth
	local studHeight = numBlocksXY * blockWidth
	return Vector3.new(x * blockWidth - studWidth/2 - blockWidth/2, blockWidth/2, y * blockWidth - studHeight/2 - blockWidth/2)
end

The Vector3 returned from this function can be used to set the model’s position in the world after it is cloned.

For each item in the 2-dimensional array, you can select a map model from ReplicatedStorage, clone it, and move the cloned model to a Vector3 position.

This should be enough to get you started on map generation.