Why can't I save a table with more than 1 value in my datastore?
I'm trying to save 2 values, strength and stamina. I want to save them both as a table in 1 datastore. I know this is possible, but it just isn't working. What am I doing wrong?
02 | local players = game:GetService( "Players" ) |
03 | local DSService = game:GetService( 'DataStoreService' ):GetDataStore( 'SecretTokenAboutAvatarwwww' ) |
05 | players.PlayerAdded:Connect( function (player) |
06 | local PlayerStats = Instance.new( 'Folder' , player) |
07 | PlayerStats.Name = 'PlayerStats' |
08 | local str = Instance.new( 'IntValue' , PlayerStats) |
10 | local stm = Instance.new( 'IntValue' , PlayerStats) |
13 | local uniquekey = "stats-" ..player.userId |
14 | local GetSaved = DSService:GetAsync(uniquekey) |
16 | print (GetSaved [ 1 ] , GetSaved [ 2 ] ) |
17 | str.Value = GetSaved [ 1 ] |
18 | stm.Value = GetSaved [ 2 ] |
20 | DSService:SetAsync(uniquekey, { 0 , 0 } ) |
02 | local Players = game:GetService( "Players" ) |
03 | local DSService = game:GetService( 'DataStoreService' ):GetDataStore( 'SecretTokenAboutAvatarwwww' ) |
05 | Players.PlayerRemoving:Connect( function (player) |
06 | local userId = "stats-" ..player.userId |
07 | local data = { player.PlayerStats.Strength.Value,player.PlayerStats.Stamina.Value } |
09 | local success, result = pcall ( function () |
10 | DSService:UpdateAsync(userId, data) |