So I'm making a datastore script and the console says the data is saving and loading. I do not understand why the data is still set to 0 when I leave and join.
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-robux")
end)
if success then
robux.Value = data
else
print("There was an error whilst getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-robux",player.leaderstats.robux.Value)
end)
if success then
print("Player Data successfully saved!")
else
print("There was an error when saving data")
warn(errormessage)
end
end)

2 comments
Are you getting the same problem in a server?
this happens to me too, i can't find the solution.