Im trying to save a table and I did this
the script is basically supposed to print 10 more of every value but instead it prints 0 everytime
local DataStore = game:GetService("DataStoreService"):GetDataStore('TestingStore') local Tabl = { Cash = 0, Gold =0, Diamonds = 0 } function IncrementTable(Val) Val = Val + 10 end function LoopToPrint(Table) for i,v in pairs(Table) do print(v) end end game.Players.PlayerAdded:Connect(function(plr) DataStore:GetAsync(plr.UserId) LoopToPrint(Tabl) end) game.Players.PlayerRemoving:Connect(function(plr) IncrementTable(Tabl.Cash) IncrementTable(Tabl.Diamonds) IncrementTable(Tabl.Gold) LoopToPrint(Tabl) DataStore:SetAsync(plr.UserId,Tabl) end)
You never set Tabl
to the table you loaded on join. See on line 25 where you haven't assigned the function result to a variable? That's your problem.