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)
Hi Spookd,
local picked = math.random(1, #maps);
local picked = math.random(1, #choices);
So, if you make it:
local picked = math.random(1, #choices);
it should be fixed.
Thanks,
Best regards,
~~ KingLoneCat