I am trying to make a game and the value of the cost won't go up. The error is one that I have never gotten before. Error: Players.Player1.PlayerGui.BuyGui.BuyFrame.ImageButton.Buy:6: attempt to perform arithmetic on upvalue 'cost' (a userdata value)
local persec = script.Parent.Parent.Parent.Parent.ClickGui.PerSec local money = script.Parent.Parent.Parent.Parent.ClickGui.Number local cost = script.Parent.Cost script.Parent.MouseButton1Click:connect(function() if money.Value > (cost - 1) then persec.Value = persec.Value + 0.1 money.Value = money.Value - cost cost.Value = cost.Value + (cost.Value * 1.06) end end)
You wrote
money.Value = money.Value - cost
But cost
is a NumberValue object. You can't add ROBLOX objects -- that wouldn't make sense (this is the error -- a NumberValue is a userdata)
You should have written cost.Value
That same goes for line 6.