I've made three scripts, one was a leaderboard script, another was save and the final was load. The leaderboard script worked fine except when it came to the save and load scripts, they weren't showing errors but when I loaded the game, they would load to a save I did almost 5 minutes before that. Here's the code: Save Script
local DS = game:GetService("DataStoreService"):GetDataStore("PoloBear_PP") game.Players.PlayerRemoving:connect(function(player) local pointsToSave = (script.Parent.Parent.leaderstats:FindFirstChild("Promotion Point").Value) DS:SetAsync("pp", pointsToSave) end) game.OnClose = function(player) print("Finishing final tasks") wait(10) print("Done") end
Load
local DS = game:GetService("DataStoreService"):GetDataStore("PoloBear_PP") game.Players.PlayerAdded:connect(function(player) wait(10) local savedPoints = DS:GetAsync("pp") if savedPoints then script.Parent.Parent.leaderstats:FindFirstChild("Promotion Points").Value = savedPoints[1] else local valuesToSave = (script.Parent.Parent.leaderstats:FindFirstChild("Promotion Points").Value) DS:SetAsync("pp", valuesToSave) end end)
It's working but I'm trying to make it, so if you switch servers it will still be there, I don't want a delay is just the problem, I'm not sure if it is because its a one person server if that's the reason why or if it's not loading correctly.