Generating random parts on chunks

Hello, so I guess I’m also approaching the whole Backrooms genre of game. In fact before even messing with this project I wanted to work on a procedurally generated map. However I’m fairly new to this type of complex scripting.

Basically my approach to this problem, was to create a chunk like system, like you’d see in minecraft. I’ve managed to create the chunks on a 15x15 grid.

local chunkGeneration = {}

local X = 15
local Z = 15

local grid = {}

for x = 1 , X do
	grid[x] = {}
	
	
	for z = 1, Z do
		grid[x][z] = math.random() * 15
	end
	
end


local FloorFolder = Instance.new("Folder")
FloorFolder.Name = ("Floors")
FloorFolder.Parent = workspace


for x = 1, X do
	for z = 1, Z do
		local floor = Instance.new("Part")
		floor.Anchored = true
		floor.Position = Vector3.new(x*30, 0, z*30)
		floor.Size = Vector3.new(30, 1, 30)
		floor.Parent = FloorFolder
		floor.Name = ("Floor")
	end
end




return chunkGeneration

And it works alright, basically generating parts with the size of 30,1,30 and along X 15 and Z 15. Now for the more complex part of the script that I can’t imagine a way of approaching it. I want it to generate random walls on each chunk, pretty much making it a liminar space like you see in the Backrooms.

Of course a wall can’t generate in the place of another wall, thus not letting walls clip through themselves. But I’d like it to be able to generate 2 or 3 walls in the same chunk even.

However if you know a way to make the script I sent above way more efficient I’d gladly accept your suggestions!

Now if you have any suggestions, sources or even pseudo-code to help me out I’d apreaciate it a lot!

1 Like