Title: I'm having trouble with a datastore and leaderboard, I'm a beginner at datastore, can some please help?
ServerScriptServiec.leaderstats:18: attempt to index local 'saved' (a nil value)
local datastore = game:GetService('DataStoreService'):GetDataStore("Friends") game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("IntValue", player) local friends = Instance.new("IntValue", leaderstats) leaderstats.Name = 'leaderstats' friends.Name = "Friends" local uniquekey = "friends-"..player.userId local pointsvalue = player.leaderstats.Friends.Value local saved = datastore:SetAsync(uniquekey, pointsvalue) if saved then pointsvalue = saved[1] else saved:GetAsync(uniquekey, pointsvalue) end end) game.Players.PlayerRemoving:connect(function(player) local pointsvalue = player.leaderstats.Friends.Value local uniquekey = "friends-"..player.userId datastore:SetAsync(uniquekey, pointsvalue) end)