Okay now can you make the randomly generated map? It would have 5 fodder rooms (rooms with some helpful loot like speed potion, not all rooms would have this loot and this loot spawn location would be set in 3 random places of the room so 3 waypoints that I can place at my will) 2 hallway rooms with spawning items as well (forgot to say for each room it has a 25% chance of spawning an item in one of the 3 waypoints of each room, and all rooms no matter the type will only have 3 available item spawn locations) 3 important rooms (this have the same size as the fodder rooms but spawn in each one of the 3 keycards needed to escape, this means in each room there will be one key card) one nest room (a big room where the monster came from , a exit room where you put the key cards and finally 4 decoration rooms where its pretty much a window to another room where the monster left a disaster. I was thinking just make the layout generarion and then Ill just replace the generated parts with the model of each room being the correct size matching the one of the part that was generated and remember its not infinite
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Absolutely! That sounds like a great structure for a randomly generated but finite map. I’ll walk you through ✨ how to generate rooms with specific categories and spawn logic exactly as you described in Roblox Studio using parts as placeholders, so you can later replace them with the full-blown room models.
❗Overview of Requirements
You need to generate a finite layout with:
Room Type
Count
Special Notes
Fodder Rooms
5
25% chance of spawning loot at 1 of 3 spawn points
Hallway Rooms
2
Same loot chance as above
Important Rooms
3
Each contains exactly 1 keycard
Nest Room
1
Large room (Monster origin)
Exit Room
1
Where players escape with the 3 keycards
Decoration Rooms
4
Non-interactable, visual lore rooms
All rooms have 3 "item spawn points" where items may spawn (25% chance), except the important rooms which always spawn a keycard.
🚀 Step-by-step Plan (Scripter-Friendly)
We’ll build a room layout generator using Parts as placeholders for the final rooms.
-- RoomLayoutGenerator
local Workspace = game:GetService("Workspace")
local COLLECTION_FOLDER = Instance.new("Folder", Workspace) -- Holds generated layout
COLLECTION_FOLDER.Name = "GeneratedRooms"
-- Room Types to Generate
local roomTypesToCreate = {
Fodder = 5,
Hallway = 2,
Important = 3,
Nest = 1,
Exit = 1,
Decoration = 4
}
-- Room Settings
local ROOM_SIZE = Vector3.new(40, 4, 40) -- Adjust the room size to match actual model sizes
local GRID_SPACING = 45 -- Enough space between the rooms
local MAX_LAYOUT_ATTEMPTS = 200
-- Bounds for room placement
local GRID_WIDTH = 6 -- Number of rooms left/right
local GRID_HEIGHT = 6 -- Number of rooms forward/back
local GRID_ORIGIN = Vector3.new(0, 0, 0) -- Central spawn point
🔧 Step 2: Room Generator Function
Still in the same Script file, paste the following code after the config block:
lua
local function getRandomGridPosition(takenPositions)
for _ = 1, MAX_LAYOUT_ATTEMPTS do
local x = math.random(-GRID_WIDTH, GRID_WIDTH)
local z = math.random(-GRID_HEIGHT, GRID_HEIGHT)
local position = Vector3.new(x, 0, z)
if not takenPositions[position] then
takenPositions[position] = true
return position
end
end
return nil -- Failed to find position
end
local function generatePlaceholderRoom(position, roomType)
local room = Instance.new("Part")
room.Size = ROOM_SIZE
room.Anchored = true
room.Name = "Room_" .. roomType
room.Position = GRID_ORIGIN + Vector3.new(
position.X * GRID_SPACING,
ROOM_SIZE.Y / 2, -- Lifts room slightly above floor
position.Z * GRID_SPACING
)
room.BrickColor = BrickColor.new("Institutional white")
room.Transparency = 0.5
room.Parent = COLLECTION_FOLDER
-- Set tag/type to be readable later (alternative to name)
room:SetAttribute("RoomType", roomType)
-- Create 3 item spawn points in the room
local itemSpawnPoints = {}
for i = 1, 3 do
local offset = Vector3.new(
math.random(-10, 10),
1,
math.random(-10, 10)
)
local spawnPoint = Instance.new("Part")
spawnPoint.Size = Vector3.new(1, 1, 1)
spawnPoint.Position = room.Position + offset
spawnPoint.Anchored = true
spawnPoint.Name = "ItemSpawn_" .. i
spawnPoint.BrickColor = BrickColor.new("Bright yellow")
spawnPoint.Parent = room
table.insert(itemSpawnPoints, spawnPoint)
end
-- Spawn Items (25% chance) - only for fodder/hallway
if roomType == "Fodder" or roomType == "Hallway" then
if math.random() < 0.25 then
local randomSpawn = itemSpawnPoints[math.random(1, #itemSpawnPoints)]
local lootItem = Instance.new("Part")
lootItem.Size = Vector3.new(2, 2, 2)
lootItem.Position = randomSpawn.Position + Vector3.new(0, 2, 0)
lootItem.BrickColor = BrickColor.Green()
lootItem.Anchored = true
lootItem.Name = "SpeedPotionLoot"
lootItem.Parent = room
end
end
-- Spawn Keycards in Important rooms (always one)
if roomType == "Important" then
local randomSpawn = itemSpawnPoints[math.random(1, #itemSpawnPoints)]
local keycard = Instance.new("Part")
keycard.Size = Vector3.new(1, 0.5, 2)
keycard.Position = randomSpawn.Position + Vector3.new(0, 1.5, 0)
keycard.BrickColor = BrickColor.Red()
keycard.Anchored = true
keycard.Name = "Keycard"
keycard.Parent = room
end
end
▶️ Final Step: Initialization Code
Now generate all rooms:
lua
-- Start Layout Generation
local usedPositions = {}
print("Generating room layout...")
for roomType, count in pairs(roomTypesToCreate) do
for i = 1, count do
local gridPos = getRandomGridPosition(usedPositions)
if gridPos then
generatePlaceholderRoom(gridPos, roomType)
else
warn("Could not place room of type: " .. roomType)
end
end
end
print("⛏️ Room layout generated. Replace parts with models to complete the map.")
📦 What You Get
When you run the game in Studio:
You'll see a set of colored transparent placeholder parts.
Each represents a room.
Their names (e.g., Room_Fodder, Room_Important) let you identify them.
Each room has 3 small ItemSpawn markers.
Some will contain:
A green cube (loot speed potion item) with 25% chance
A red card (keycard) in each important room
You can now write a tool or manually select each generated room and replace it with the proper model.
🌱 Future Improvements
Make a template system (insert correct models automatically)
Re-run generation on each round start
Use Room Templates via ReplicatedStorage:GetChildren()
Save nav data (for your monster)
Would you like a button to regenerate the layout or to automatically swap placeholder blocks with the correct models next?