How can I make Random Map Generation?

I’m trying to make a random map generator and I’m not really sure how to, It’s a recreation of SCP:CB where there’s corridors and rooms, I think how they do it is divide each section into grids and see what rooms are compatible to “match” onto it, leaving some blanks squares. Though, I don’t actually know how to do this.

(Image of what I mean)

I few problems I’ve encountered are stuff like script exhaustion from checking ~20 possible matches for each door on a grid (Probably around 5000 checks they do for each map) and that’s basically where I’m currently stuck at. Does anyone know how to fix this?

2 Likes

if you’re encountering script exhaustion add waits to your code

2 Likes

That doesn’t solve the issue - As I said it needs to run ~5000 times, even with the lowest possible wait (29 milliseconds) will take too long. I also said I’m stuck on that part and never got any closer to the goal.

Try using RunService.Heartbeat:Wait() or task.wait() instead of using the normal “wait()”

They give the same delay, and again, that’s not the only thing stopping me, there’s a lot of other issues as stated in the original post.

So does this mean like, the script stops running for a while?
I dont know how script exhaustion works.

If that is the case just make a loading screen and let everyone wait for the map to load.
I really have no idea lol

Script exhaustion is where a script runs too much code in a short amount of time, and the script stops running because of it. This is a safeguard setting defaulted by Roblox and can be turned off (it’s primarily used to tell you that something is wrong)

1 Like