local guns = {"Starter", "Rifle"}
local gunVariables = {
{
cost = 0,
level = 5
},
{
cost = 200,
level = 5
}
}
chosenClass.Changed:connect(function(newClass)
gunLabel.Text = newClass
for i, v in pairs(guns) do
if v == newClass then
for n, k in pairs(gunVariables[i]) do
print(n, k)
if n == level then
print(n, k)
levelLabel.Level.Text = k
end
end
end
end
end)
I'm trying to iterate through the table of values. Each gun has its own level and cost. How can I get that to work in my code. I have if n == level then to make sure it's got the right variable in the table, but it's not working. Please help

1 comment
It should be if n == 'level'; the script editor gives you a warning about this in the form of a blue underline, as well.