local values = {} values[1]={ xp_requirement=200 } --Make a table in a table, containing all the values --Nothing else needed here, as you never level up to level 1 values[2]={ xp_requirement=450, cash_bonus=200, maxhp_bonus=0 } while wait(3) do local level = script.Parent.Parent.Parent.TextLabel.Crisps local experience = script.Parent.Parent.Parent.TextLabel.Chocolate if experience.Value >= values[level.Value[1]] then -- possible solution level.Value = level.Value + 1 cash = cash + values[level.Value[2]] end end
I've been trying to make a level up script which rewards upon level up using tables, however, when it runs in game, nothing happens and I get the following error in console: https://gyazo.com/f7aa075107da11989da8e6dd16ca5d1b
I think I have the solution. What is happening is that the value for level is not a table. Without knowing your hierarchy, it seems to me that crisps is a number or int value. What is happening is your are trying to use the number as a table, which is what causes your error. To fix it, I would change line 11 to:
if experience.Value >= values[level.Value].xp_requirement then
That should work, from what I can gather from your code. I hope this helps.