-
Hi everyone. I am making a map generation script for a new game. It currently works how it was written to, but I’m looking for a better way to go about this.
-
The issue is that the system is very random, creating tons of spaces you can’t access whatsoever.
-
So far, I’ve rewrote it twice, each time yielding the same results. My game is a bit too unique, and none of the other map generation scripts would work too well with the system I have.
local typenumber = 0
local roomnumber = 0
wait(1)
for i,v in pairs(workspace.Gens:GetChildren()) do
wait(0.2)
typenumber = math.random(1,10)
if typenumber == 1 or typenumber == 2 then
roomnumber = math.random(1,4)
if roomnumber == 1 then
local clone = game.ServerStorage.Corners.One:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
elseif roomnumber == 2 then
local clone = game.ServerStorage.Corners.Two:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
elseif roomnumber == 3 then
local clone = game.ServerStorage.Corners.Three:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
elseif roomnumber == 4 then
local clone = game.ServerStorage.Corners.One:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
end
elseif typenumber == 3 or typenumber == 4 or typenumber == 5 or typenumber == 6 or typenumber == 7 then
roomnumber = math.random(1,2)
if roomnumber == 1 then
local clone = game.ServerStorage.Halls.One:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
elseif roomnumber == 2 then
local clone = game.ServerStorage.Halls.Two:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
end
elseif typenumber == 8 then
if roomnumber == 1 then
local clone = game.ServerStorage.Spawns.One:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
elseif roomnumber == 2 then
local clone = game.ServerStorage.Spawns.Two:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
elseif roomnumber == 3 then
local clone = game.ServerStorage.Spawns.Three:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
elseif roomnumber == 4 then
local clone = game.ServerStorage.Spawns.One:Clone()
clone.Parent = v
clone.Center.Place.Part1 = v
end
end
end
If anyone has ideas for how to make this system better, or just something that I should add or change, please let me know.