Table values returning nil

Hello, I’m making a script that changes a tool’s name and a value in the tool to be something in the table. But for some reason, it works for the first value but then gives me an error.

local toolType = script.Parent:FindFirstChild("ToolType")
local tool = script.Parent

local values = {
	[0] = {"Tool",5},
	[1] = {"Tool v2",100},
	[2] = {"Tool v3",500},
	[3] = {"Tool v4",2500},
	[4] = {"BugTool",25},
	[5] = {"EpicTool",5000}
}

local function value()
	for value,name in ipairs(values) do
		if toolType.Value == value then
			tool.Name = name[value]
			tool.AddValue.Value = name[2]
		end
	end
end

toolType:GetPropertyChangedSignal("Value"):Connect(value)

It’s just very weird. Even I don’t know how it works and I coded it!
The error for anyone that was wanting to know:

Players.MediaHQ.Backpack.Tool.CheckValue:16: invalid argument #3 (string expected, got nil)

Try changing the line to this.

tool.Name = name[1]

Also, instead of this whole thing

local function value()
	for value,name in ipairs(values) do
		if toolType.Value == value then
			tool.Name = name[value]
			tool.AddValue.Value = name[2]
		end
	end
end

you can just do this.

local function value()
	local Data = values[toolType.Value]
	tool.Name = Data[1]
	tool.AddValue.Value = Data[2]
end

Somehow this worked. Thank you!