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("NumberValue")
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 failed")
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 saved")
else
print("data failed")
warn(errormessage)
end
end)
When I open up the Explorer tab, and find the value and change it in the Properties window, it does not save, even when it prints, "data saved". It also does not save when I update the value in the Command Bar. Why is that, and how can I resolve this error?

1 comment
Where is the errormessage then?