Hey so when a player enters my game, I save the following data into a dict called local storage = {}
The data that is saved is
local tab = { name = player.Name, userId = player.UserId, coins = 300 }
Now I have a EditStorage function which changes the coins value
> function module:EditStorage(id,Table,EditType,Amount) > if id == nil or Table == nil or EditType == nil then return end > for i,v in ipairs(storage) do > if v.userId == id then > if EditType == "Set" then > v.Table = Amount > warn("Set") > elseif EditType == "Increment" then > v.Table = v.Table + Amount > return v.Table > end > end > end > end
When I run this store:EditStorage(id,"coins","Increment",200)
It does print 500 (meaning it did properly increment) However when it does this function again it prints 500 again, meaning that the table “coins” is not being updated from this function.
What I want to have happen
I want the storage for that player id to update the coin value, at the minute its only changing for the function and isn’t saving properly. If any addition Information is needed then let me know!
THE STUFF BEING PASSED AS PARAMETERS INTO EDITSTORAGE
Id = player id
Table = the specific var the player wants edited. In this scenario is it “coins”
EditType = what type of operation you want done, via incrementing or setting
Amount = Integer, the value