Keep getting attempt to index nil with "Value"

function round.ChooseMap ()

local choices = {}
for i = 1 , #maps do
	if maps[i]:IsA("Model") then
		table.insert(choices, maps[i])
	end
end
local picked = choices[math.random(#maps)]

chosenmap.Value = picked.Name  -- Error is on this line. 
end

Been stuck on this for about 2 hours. Any help is apprecieated.

Do you have a Value named Name? If so the game might be confusing it with the models name

Is there a variable for chosenmap?, if yes could you send it

I meant index nill with name not value. but i dont have a value named Name. I have one named ChosenMap which is should be getting the values name but gives the index nil

local chosenmap = script.ChosenMap

Meant to put it at top my apoligies

for i, Maps in pairs(maps) do
if Maps:IsA("Model") then
table.insert(choices, Maps)
end
local picked = choices[math.random(1, #choices)]

Choosenmap.Value = tostring(Choices[picked])

end

It does work but for some reason changes the chosenmap values name to nil. Any idea why?

you dont need tables for this

local picked = (MAPS):GetChildren()
local random = picked[math.random(#picked)]