I am trying to choose maps from the ReplicatedStorage and set the value of a StringValue to the name of the map:
local choices = {}
function choose()
for i = 1,#maps do
if maps[i]:IsA("Model") then
table.insert(choices,maps[i])
end
end
local picked = math.random(1,#maps)
chosen.Value = choices[picked].Name
end
But an error pops up every time and I can't figure out why:
Workspace.CurrentMap.Script:24: attempt to index field '?' (a nil value)

8 comments
After I changed it to that, it says: Workspace.CurrentMap.Script:23: bad argument #2 to 'random' (interval is empty)
Try printing #choices after for loop and tell me what it prints.
it printed 0
That's the problem.You can't pick a map if there isn't one in the choices table. Make sure maps has models under it.
Okay thats fixed but now it says this: Workspace.CurrentMap.Script:25: bad argument #3 to 'Value' (string expected, got nil)
Try printing choices[picked]. Is #choices still 0?
It for some reason prints table: 2FF9A76C
Its probably because i had to switch the [#choices + 1] = maps[i] around to maps[i] = #choices + 1 because when I do that it says that it got an unexpected '[', but I dont know how to switch that around and I dont know if it is the problem either way