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:
local datastore = game:GetService("DataStoreService"):GetDataStore("Savedata") game.Players.PlayerAdded:Connect(function(player) local stats = Instance.new("Folder", player) stats.Name = "leaderstats" local wins = Instance.new("IntValue") wins.Name = "Wins" wins.Parent = stats local coins = Instance.new("IntValue") coins.Name = "Coins" coins.Parent = stats local key = "player"..player.userId local SavedValues = datastore:GetAsync(key) if SavedValues then wins.Value = SavedValues(1) coins.Value = SavedValues(2) else local ValuesToSave = {wins.Value, coins.Value} datastore:SetAsync(key, ValuesToSave) end end)
Howdy!
To index a table, you use brackets - not parenthesis. Replace lines 23 and 24 with what I got below and it should work.
wins.Value = SavedValues[1] coins.Value = SavedValues[2]