I'm new to DataStoreSystems, but I watched this YouTube video on how to make one for my wins system, and even though the points go up, they don't permanently save. When I log back in, my wins just set back to 0. What did I do wrong?
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-Wins")
end)
if success then
wins.Value = data
else
print("Data not saved from success")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-Wins",player.leaderstats.Wins.Value) end)
if success then
print("Data successfully saved")
else
print("Data not saved")
warn(errormessage)
end
end)

3 comments
I hope this works for you! If it does then please mark this as answered.
How would I add a leaderstats like thing where it displays the value of the wins on the side into this script?
For leaderstats you would need a regular script. Also, Did you place this into a ModuleScript? I forgot to tell you that.