Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Error: attempt to perform arithmetic on global 'cost1' (a table value)?

Asked by 5 years ago

So, I am trying to store the cost of something in a table. But the issue is that the cost will not go up and the error comes up. Here is the script.

cost1 = {80,160,200,210,230,250,300,301,302,303,304,305,306,307,308,309,310,311}
CostChange.OnServerInvoke = function(player)
    local cost = player.UpgradeCosts.BackpackUpgrade
    local lev = player.backpack.WeightLevel1
    lev.Value = lev.Value + 1
    cost.Value = cost.Value[#cost1 + 1]
end

Thanks

0
Wow, this is unusual. Maybe you forgot the length operator in your actual script? DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by
Gojinhan 353 Moderation Voter
5 years ago

This is kind of difficult to answer, you've just given a script with some unknown variables. We hardly know what you're trying to do.

But the error is that you're trying to take a table, and add 1 to it. Once again its hard to find out your intention but if you're trying to add 1 to the table as a value, do table.insert(cost1, 1)

But if you want to add every number in the table by 1 then you're better off just taking every table entry and adding 1 to that, instead of trying to do math on a table object.

0
I honestly dont know why i have the +1. But the cost1 table. As the server is activated. Im tryonf to change a value to the number in the cost1 table. And as the server is activated each time, the cost value goes up each time to the numbers in the table. ChefDevRBLX 90 — 5y
Ad

Answer this question