Ad
Log in to vote
0

How do i clone a whole room?

Asked by 8 days ago

I am making a randomly generated maze but I don't know how to copy the walls with the floor right now I only have generated floor and nothing else

my generation works like this:

there are 3 parts they are the room templates There is a part that is coping randomly 1 of these 3 rooms

Thanks in advance :)

1 answer

Log in to vote
0
Answered by 8 days ago
Edited 8 days ago

use math.random and follow the code, im not sure if it works create a numberValue in Workspace, group the rooms into 3 different ones (like what you said, you had 3 different rooms)

name your numbervalue and replace each "YourNameOfYourValue" with the actual of the numbervalue.

local number = math.random(0, 2)
local buildingNumber1 = --place of where your first building is
local buildingNumber2 = --place of where your second building is
local buildingNumber3 = --place of where your third building is

game.Workspace.YourNameOfYourValue.Value = number

if game.Workspace.YourNameOfYourValue.Value == "0" then
    buildingNumber1:Clone()
elseif game.Workspace.YourNameOfYourValue.Value == "1" then
    buildingNumber2:Clone()
else
    buildingNumber3:Clone
end

edit: use this script, I forgot some stuff (also put your mazes into somewhere outside Workspace)

local number = math.random(0, 2)
local buildingNumber1 = --place of where your first building is
local buildingNumber2 = --place of where your second building is
local buildingNumber3 = --place of where your third building is

game.Workspace.YourNameOfYourValue.Value = number

if game.Workspace.YourNameOfYourValue.Value == "0" then
    local clone1 = buildingNumber1:Clone()
    clone1.Parent = workspace
elseif game.Workspace.YourNameOfYourValue.Value == "1" then
    local clone2 = buildingNumber2:Clone()
    clone2.Parent = workspace
else
    local clone3 = buildingNumber3:Clone
    clone3.Parent = workspace
end
Ad

Answer this question