I'm following a tutorial I found in the RBLX forums but for some reason I can't get the save to load? Can anyone show me what i'm doing wrong and and a method on how to correct it?
Also I was wondering what are some ways i can switch from the unreliable "Save on Remove" to a system that saves every 60 seconds?
saveAs = "LS"
dataStore = game:GetService("DataStoreService"):GetDataStore(saveAs)
game.Players.PlayerRemoving:connect(function(player)
player:WaitForDataReady() --To load stuff
wait(1) --In case of crash and prevent being homeless
stats = player["leaderstats"]:GetChildren() --Change "leaderstats" to your stats
for i = 1, #stats do --Creates a loop for every stats
dataStore:SetAsync(stats[i].Name, stats[i].Value .. player.userId)
end
end)
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady() --To load stuff
wait(1) --In case of crash and prevent being homeless
stats = player["leaderstats"]:GetChildren() --Change "leaderstats" to your stats
for i = 1, #stats do --Creates a loop for every stats
stats[i].Value = dataStore:GetAsync(stats[i].Name .. player.userId)
end
end)

2 comments
Ohhhhhh I see what I did wrong. Thank you for your help sir.
No problem.