Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I keep getting a weird error in output whenever I try to save stats using UpdateAsync?

Asked by 5 years ago
Edited 5 years ago

Whenever I try to save a player's stats this pops up in the output.

" 12:00:00.620 - 104: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters. 12:00:00.620 - Stack Begin 12:00:00.621 - Script 'ServerScriptService.Enabled.Stats', Line 135 12:00:00.621 - Stack End"

Line 133 - game.Players.PlayerRemoving:connect(function(Player)
    local key = Player.userId
    DataStore:UpdateAsync(tostring(key), function(oldD)
        D={}
        table.insert(D, 1, game.ServerStorage[Player.Name].Stat1.Value)
        table.insert(D, 2, game.ServerStorage[Player.Name].Stat2.Value)
        table.insert(D, 3, game.ServerStorage[Player.Name].Stat3.Value)
        table.insert(D, 4, game.ServerStorage[Player.Name].Stat4.Value) 
        table.insert(D, 5, game.ServerStorage[Player.Name].Stat5.Value)
        table.insert(D, 6, game.ServerStorage[Player.Name].Stat6.Value)
        table.insert(D, 7, game.ServerStorage[Player.Name].Stat7.Value)
        table.insert(D, 8, game.ServerStorage[Player.Name].Stat8.Value)
        table.insert(D, 9, game.ServerStorage[Player.Name].Stat9.Value)
        table.insert(D, 10, game.ServerStorage[Player.Name].Stat10.Value)
        table.insert(D, 11, game.ServerStorage[Player.Name].Stat11.Value)
        table.insert(D, 12, game.ServerStorage[Player.Name].Stat12.Value)
        table.insert(D, 13, game.ServerStorage[Player.Name].Stat13.Value)
        table.insert(D, 14, game.ServerStorage[Player.Name].Stat14.Value)
        table.insert(D, 15, game.ServerStorage[Player.Name].Stat15.Value)
        table.insert(D, 16, game.ServerStorage[Player.Name].Stat16.Value)
        table.insert(D, 17, game.ServerStorage[Player.Name].Stat17.Value)
        table.insert(D, 18, game.ServerStorage[Player.Name].Stat18.Value) 
        table.insert(D, 19, game.ServerStorage[Player.Name].Stat19.Value)
        table.insert(D, 20, game.ServerStorage[Player.Name].Stat20.Value)
        table.insert(D, 21, game.ServerStorage[Player.Name].Stat21.Value)
        table.insert(D, 22, game.ServerStorage[Player.Name].Stat22.Value)
        D = D
        return D
    end)
Line 162 - end)

Answer this question