Script:
local datastoreservice = game:GetService("DataStoreService")
local mydatastore = datastoreservice:GetDataStore("mydatastore")
game.Players.PlayerAdded:Connect(function(player)
local playerid = "Player_" .. player.UserId
local data = mydatastore:GetAsync(playerid)
local ld = Instance.new("Folder", player)
ld.Name = "leaderstats"
local rebirthCount = Instance.new("IntValue", ld)
rebirthCount.Name = "Rebirth"
local damageCount = Instance.new("IntValue", ld)
damageCount.Name = "Damage"
local plusDamage = Instance.new("IntValue", ld)
plusDamage.Name = "PlusDamage"
local wins = Instance.new("IntValue", ld)
wins.Name = "Wins"
if data then
rebirthCount.Value = data["Rebirth"]
damageCount.Value = data["Damage"]
plusDamage.Value = data["PlusDamage"]
wins.Value = data["Wins"]
else
rebirthCount.Value = 0
damageCount.Value = 0
plusDamage.Value = 1
wins.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local datatobesaved = {
rebirth = player.leaderstats.Rebirth.Value,
damage = player.leaderstats.Damage.Value,
plusDamage = player.leaderstats.PlusDamage.Value,
win = player.leaderstats.Wins.Value
}
local playerid = "Player_" .. player.UserId
print("SS", player, playerid)
local success, err = pcall(function()
mydatastore:SetAsync(playerid, datatobesaved)
end)
print(success)
if success then
print("data saved!")
else
print("data faield to save!")
end
end)
Good afternoon, I found a guide on devForum where I found information on how to make good data saving. But for some reason they are not saved, here is the guide if anything: How to To save Data - Tutorial
If anything, in the settings I enabled everything as it should be, and the problem is that the first print is output and the second is not, here is the Output.
I mean, it doesn’t want to work, the question is why?