Answered by
F_F 53
7 years ago
Firstly, you would need to acquire DataStoreService and save the Data inside a table. Secondly, you will look through the DataStore where you are saving data if any Data is found you will use SetAsync to represent it otherwise the default.
local DataStore = game:GetService("DataStoreService")
local DS1 = DataStore:GetDataStore("PlayerData") -- This is where you will save your data to.
game.Players.PlayerAdded:Connect(function(Player)
local User = "user-" .. tostring(Player.UserId) -- Get the player's UserId
local Data = Instance.new("Folder", Player) -- Instance a folder inside the Player
local Exp = Instance.new("IntValue", Player) -- Instance an IntValue inside the Data folder.
04 | local Save = DS 1 :GetAsync(user) |
09 | local ProgressToSave = { Exp.Value } |
10 | DS 1 :SetAsync(user, ProgressToSave ) |
end)
-- Once the player is leaving the game you want to save their achievements.
game.Players.PlayerRemoving:Connect(function(Player)
local User = "user-" .. tostring(Player.userId)
local SaveProgress = {Player.Data.Exp.Value}
DS1:SetAsync(user, SaveProgress)
end)
Hopefully, I helped.