I originally thought this was an issue with datastore, but upon further examination I determined that the data was saving, but the Rubles value from the player removing function is getting the wrong Rubles Value. For instance, when I set the Rubles value to 25, and then I click stop, even though the Rubles Variable is 25, the script still outputs 10 when printing savetable. The reason I know this to be true is because I edited the line "local Savetable = {plr.leaderstat.Rubles.Value}" to "local Savetable = {plr.leaderstat.Rubles.Value+2}". And next time I load the game, I have 12. So I'm wondering why incorrect data is being retrieved here.
local DataStoreService = game:GetService('DataStoreService')
local moneyStore = DataStoreService:GetDataStore('Djmaster444TestStore03')
game.Players.PlayerAdded:connect(function(plr)
plr:WaitForChild(plr.Backpack.Name)
-- Define variables
local uniquekey = 'id-'..plr.userId
local leaderstat = Instance.new('NumberValue', plr)
local savevalue = Instance.new('NumberValue')
leaderstat.Name = 'leaderstat'
savevalue.Parent = leaderstat
savevalue.Name = 'Rubles'
savevalue.Value = 10.00
-- GetAsync
local GetSaved = moneyStore:GetAsync(uniquekey)
print(GetSaved[1])
if GetSaved then
savevalue.Value = GetSaved[1]
else
local NumbersForSaving = {savevalue.Value}
moneyStore:SetAsync(uniquekey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
saveData(plr)
end)
function saveData(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.leaderstat.Rubles.Value}
moneyStore:SetAsync(uniquekey, Savetable)
end

5 comments
I appreciate the help, but I'd also like to know the data is not saving.
You can go check my module to check out how it works
or check out here https://pastebin.com/VxSNp0cV It has pcalls because there might be a error while loading/saving data so the pcall wont error and the script wont break down
It's not datastore. I did some diagnosing, and I've realized that savetable is not reading the the "Rubles" value correctly. I'm going to edit the question to accommodate this.
Oh ok