Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Wow, this is unusual. Maybe you forgot the length operator in your actual script?

1 answer

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.

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.