ServerScriptService.leaderstats:23: attempt to call a table value. Wheres the error?
When I was making my saved leaderboard stats, I got this error. Does anyone know how to fix it? The error is supposedly in line 23 by the way.
Script:
01 | local datastore = game:GetService( "DataStoreService" ):GetDataStore( "Savedata" ) |
03 | game.Players.PlayerAdded:Connect( function (player) |
06 | local stats = Instance.new( "Folder" , player) |
07 | stats.Name = "leaderstats" |
09 | local wins = Instance.new( "IntValue" ) |
13 | local coins = Instance.new( "IntValue" ) |
17 | local key = "player" ..player.userId |
19 | local SavedValues = datastore:GetAsync(key) |
23 | wins.Value = SavedValues( 1 ) |
24 | coins.Value = SavedValues( 2 ) |
28 | local ValuesToSave = { wins.Value, coins.Value } |
29 | datastore:SetAsync(key, ValuesToSave) |