I have a Points Leaderboard in our Cafe Game. It works fine. But when someone leaves and rejoins the Same server their Points get blanked. If they join another server it doesn't happen. Here is the script of when they leave -
game.Players.PlayerRemoving:connect(function(player) if array[player.Name] ~= nil then game:GetService("DataStoreService"):GetDataStore("Points"):UpdateAsync("user_"..player.userId, function(oldValue) local newValue = array[player.Name] return newValue end) array[player.Name] = nil end end)
local httpserv = game:GetService("HttpService") game.Players.PlayerRemoving:connect(function(player) if array[player.Name] ~= nil then game:GetService("DataStoreService"):GetDataStore("Points"):SetAsync("user_"..player.userId, httpserv:JSONEncode(array[player.Name])
Try this. What I am doing is encoding the array so that it has a proper format when sending it to the web. I am encoding it into JSON so that it can be sent. Remember to use
httpserv:JSONDecode(DataStoreGoesHere)
to make it back an array, otherwise you'll get a string!
Not sure if it will work, try it.
And remember you must be on a live game. Studio does not save data stores.