How can I generate rooms continuously?

So, a while ago, I made this topic:

but for some reason forgot about it, so I’m making the topic again and making it clearer in hopes of getting help

So, I plan to make a game like “Rooms”, you may have heard of it

If you haven't it's this game

Rooms - Roblox

my goal is to generate rooms procedurally out of a set of premade rooms, preferably once a player enters a room. As in, the player will enter one room, and once they do, another one generates, so on and so forth

I have old code I can use, but I’m assuming I’d need to modify it. a lot

Here's the (old) code
local visited = {}
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		while true do
			wait(0.01)
			for i = -20,1 do
				local zPos = math.floor((char.HumanoidRootPart.Position.Z + i * 20) / 20 + 0.5) * 20
				if visited[zPos] == nil then
					visited[zPos] = script.Room:Clone()
					print("Room Cloned Successfully")
					local p = visited[zPos]

					p:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,0.25,zPos)))

					p.Parent = workspace.Room
				end
			end
		end
	end)
end)

i already have the rooms in ReplicatedStorage, how would I put this plan into action?
Thank you in advance

How are you planning to generate procedurally rooms when they’re already premade?

that was the old topic, I thought it was the same thing since it’s… well, a random room?

still don’t understand your point, you’re going to generate these rooms from scratch, or do you have them premade and just want to clone + position it?

I have them premade in replicated storage, I’m cloning them randomly so it’s continual just like the original game
if you’re not gonna provide any help and just tell me what I’m saying is wrong I don’t see you needing to comment on my post in the first place

If they’re premade rooms, you could have points in which they’ll connect to each on each surface normal of the base part of the room. You could clone a new room, and attach it to one of the surface normals of the previous room that was made, offsetting it from the surface normal by the size of the room so it connects seamlessly.

Surface normal referring to just a side of the part basically. (so left, right, back, or forward)

1 Like

i was actually thinking of using hitboxes or joint points or whatever they’re called. The problem is that my old code doesn’t use those, it generates them based on the position of the player and how far they’ve travelled. I’m wondering how I could incorporate it into this