Attempt to index nil with Name using table

Hi!
This is my table code.

local available = 0
local ID = 0

local maps = {
	["1"] = {
		["Name"] = "Toxic Town",
		["Thumbnail"] = "rbxassetid://8950721768",
		["PlaceID"] = "8950403502",
	}
}

function Refresh()
	available = 1
end
local function NewRound()
	Refresh()
	local Map = math.random(1, available)
	print(Map)

	script.Parent.title.Text = maps[Map]["Name"]
	script.Parent.Thumbnail.Image = maps[Map]["Thumbnail"]
	ID = maps[Map]["PlaceID"]
end

while task.wait(15) do
	NewRound()
end

game.Workspace.Elevator1aTPPart.Touched:Connect(function(a)
	local partParent = a.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		game:GetService("TeleportService"):TeleportAsync(ID, game.Players[humanoid.Parent.Name])
	end
end)
local available = 0
local ID = 0

local maps = {
	["1"] = {
		["Name"] = "Toxic Town",
		["Thumbnail"] = "rbxassetid://8950721768",
		["PlaceID"] = "8950403502",
	}
}

function Refresh()
	available = 1
end
local function NewRound()
	Refresh()
	local Map = math.random(1, available)
	print(Map)

	script.Parent.title.Text = maps[Map]["Name"]
	script.Parent.Thumbnail.Image = maps[Map]["Thumbnail"]
	ID = maps[Map]["PlaceID"]
end

while task.wait(15) do
	NewRound()
end

game.Workspace.Elevator1aTPPart.Touched:Connect(function(a)
	local partParent = a.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		game:GetService("TeleportService"):TeleportAsync(ID, game.Players[humanoid.Parent.Name])
	end
end)

But, it’s not reading off of the table right. I got an error trying to set the name with maps[Map][β€œName”], but this should work.
Thanks for any help!

1 Like

β€œ1” == 49 (https://www.asciitable.com/)
1 == 1
or 1 == tonumber(β€œ1”)
or tostring(1) == β€œ1”

1 Like


I have this now, still not working.

image
Map is already a number, make it a string. β€œName” is a string. Leave it be.

1 Like

To add to that, Name, Thumbnail, and PlaceId are all strings and can be left alone

1 Like