Randomly Generated Rooms

So i am looking for a script that can generate a randomly generated rooms like in baldi’s basics plus i was trying to search for something like this but i didn’t see anything and i have no idea how to make a thing like this.


You can have a folder of different furniture models in ServerStorage or ReplicatedStorage and have a script that picks a random model and places it in the room.

For placing them on the floor, you can use the Model:MoveTo() function. You can set the PrimaryPart of the model to a part set at the bottom of the model.

If you want the model to be rotated, you should use Model:SetPrimaryPartCFrame() instead.

Can you show me an example of this in code?

If you are talking about randomly generated maps instead of unique generated rooms then create a folder and make maps and put them in the folder (maps should be a model each). Then use this script:

Maps = game.ServerStorage.Maps:GetChildren()

while task.wait(1) do
	Chosen_Map = Maps[math.random(1, #Maps)]
	Chosen_Map.Parent = workspace
	Chosen_Map.Parent = Maps

this will simply generate a random map each 10 seconds. Hope this helps!

local Objects = ReplicatedStorage:WaitForChild("Objects")

AllObjects = Objects:GetChildren()

for i = 1, 8 do --how many objects you want in the room
   local NewObject = AllObjects[math.random(1, #AllObjects)]:Clone()
   NewObject.Parent = workspace
   NewObject:MoveTo(Vector3.new(PosX, Floor.Position.Y + Floor.Size.Y / 2), PosZ)
   --[[or if you want to keep a set rotation:
   local PP = NewObject.PrimaryPart
   NewObject:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ) * CFrame.Angles(math.rad(PP.Orientation.X), math.rad(PP.Orientation.Y), math.rad(PP.Orientation.Z)))

You can find PosX and PosZ depending on what way you want to arrange the objects

1 Like