Hello. I’m having trouble with a random room gen script. (I suck at scripting btw and I haven’t scripted in a while)
Ik this script is messy, but idk any other way to do this.
local rooms = 14
local roomsdone = 0
local totalrooms = 14
local parts = script.Parent
local start = game.Workspace.RoomsStart
repeat
local currentroom = math.random(1,rooms)
if currentroom == 1 then
local room1 = script.Parent.Crates1:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 2 then
local room1 = script.Parent.Crates2:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 3 then
local room1 = script.Parent.Crates3:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 4 then
local room1 = script.Parent.Crates4:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 5 then
local room1 = script.Parent.Crates5:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 6 then
local room1 = script.Parent.Crates6:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 7 then
local room1 = script.Parent.Crates7:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 8 then
local room1 = script.Parent.Crates8:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 9 then
local room1 = script.Parent.Crates9:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 10 then
local room1 = script.Parent.Crates10:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 11 then
local room1 = script.Parent.Crates11:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 12 then
local room1 = script.Parent.Crates12:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 13 then
local room1 = script.Parent.Crates13:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
if currentroom == 14 then
local room1 = script.Parent.Crates14:Clone()
if roomsdone == 0 then
room1.Position = start.Position
end
end
roomsdone = roomsdone + 1
until roomsdone == 1
I want a certain amount of randomly chosen rooms (out of the 14 currently) to generate in front of each other, the first room going to the CFrame of this specific part, but I can’t seem to even get that to work.
If anyone can provide me with any information or write me a script, it would be much appreciated.