I am trying to choose maps from the ReplicatedStorage and set the value of a StringValue to the name of the map:
local players = game.Players:GetChildren()
local maps = game.ReplicatedStorage.Maps:GetChildren()
local currentmap = game.Workspace:WaitForChild("CurrentMap")
local chosen = script.ChosenMap
local spawner = game.Workspace.Spawn -- Change name
local choices = {maps}
function choose()
for i = 1,#maps do
if maps[i]:IsA("Model") then
maps[i] = #choices + 1 -- I was told to use '#choices + 1 = maps[i]' but it can't go like that.
end
end
local picked = math.random(1, #choices)
print(choices[picked])
chosen.Value = choices[picked].Name
wait()
end
Some of this code was changed a bit from someone in my last post.
But it just prints table: 33931ACC and an error pops up every time and I can't figure out why:
Workspace.CurrentMap.Script:25: bad argument #3 to 'Value' (string expected, got nil)

1 comment
How is the table maps created since you assign the value of choices there