I have been working on a consumable feature for my game and it was going well until the 4th line decided to give a error which i was unable to fix
The error: ReplicatedStorage.ConsumableManager:27: attempt to index number with 'GravityDisruptor'
(only shows the function that has the error)
function ConsumableManager:AddUsesLeft(Player,ConsumableName,Amount) local Stat = GetStat:Invoke(Player,"Consumables") --gets the consumable stringvalue information local Consumables = game.HttpService:JSONDecode(Stat.Get()) --gets the value which should a table if not Consumables[ConsumableName] then Consumables[ConsumableName] = 0 end Consumables[ConsumableName] = Consumables[ConsumableName] + Amount Stat.Set(game.HttpService:JSONEncode(Consumables)) --sets the stat end
I tried removing the 4th line but then the 5th line also had the same error and then removing that line makes the function useless
If it worked it would make the value something like this: {"PipeBomb":1,"Pitchfork":1,"GravityDisruptor":1}