I have been trying to make a map randomiser for the past 2 hours and i am having trouble it says "attempt to index number with 'Map'" on line 3 i have tried math.random(1, #Maps), random.new(1, #Maps) and neither have worked please help as i cant continue making a game without this working.
EDIT: I changed the code a little still dosent work NEW ERROR: ServerScriptService.MapChooser.Selector:14: attempt to index number with 'Sky'
local Maps = game.ServerStorage:WaitForChild("Maps"):GetChildren()
local Map = math.random(1, #Maps)
local MapClone = Maps[Map]:Clone()
local Intermission = game.ReplicatedStorage:WaitForChild("MapStuff"):WaitForChild("Intermission")
while wait() do
print("Intermission.")
if Intermission.Value == true then
wait()
elseif Intermission.Value == false then
print("No Longer Intermission.")
MapClone.Map.Parent = workspace
print("Cloned To Workspace.")
Map.Sky.Parent = game.Lighting
print("Lighting.")
end
end

5 comments
Try doing Map[Sky].Parent
When you are using :GetChildren() you are creating an array. So now to find a random map in that array, you need to generate a random number key(using math.random()) then you need to reference the array as you usually would. Maps[math.random(1,#Maps)]
ForeverBrown i already fixed it thanks to HappyJakeyBoy
Just giving a brief description of what is actually happening.
Oh thanks