Today when I went into studio to work on my game and tested it, I noticed that the leaderbords werent loading the saved data so I went into the main game and played it it was also happening the data was not loading it was wierd since I didint change the save script at all any idea on why this could be happening?
Thanks!
The Save script:
local DataStoreService = game:GetService("DataStoreService")
local SaveSlot = DataStoreService:GetDataStore("SaveSlotTesting")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = leaderstats
local Gems = Instance.new("IntValue")
Gems.Name = "Gems"
Gems.Parent = leaderstats
local PlayerUserId = player.UserId
local LoadedSaveData
local success, errormessage = pcall(function()
LoadedSaveData = SaveSlot:GetAsync(PlayerUserId)
end)
if success then
if LoadedSaveData then
player.leaderstats.Level.Value = LoadedSaveData.LevelSaveData
player.leaderstats.Gems.Value = LoadedSaveData.GemsSaveData
end
end
----------------------------------
end)
game.Players.PlayerRemoving:Connect(function(player)
local PlayerUserId = player.UserId
local SavedData = {---
LevelSaveData = player.leaderstats.Level.Value,
GemsSaveData = player.leaderstats.Gems.Value
}
local success, errormessage = pcall(function()
SaveSlot:SetAsync(PlayerUserId, SavedData)
end)
end)
--------------------------------------