it saves for the trash and backpack trash but not the money
Can u try print the data after it save
game.Players.PlayerRemoving:Connect(function(player)
Local data
local tableToSave = {}
for i,v in pairs(player.leaderstats:GetChildren())do
tableToSave[v.Name] = v.Value
end
local sucess, errormessage = pcall(function()
data = PlayerData:SetAsync(player.UserId,tableToSave)
end)
if sucess then
print("Data Successfully Saved!")
print(data)
else
print("Error Saving Data.")
warn(errormessage)
end
end)
I edit the script a bitâŚtry that
so at the table to save? or somewhere else
for i,v in pairs(player.leaderstats:GetChildren())do
print(i,v.Name, v.Value)
tableToSave[v.Name] = v.Value
end
Money is 0 so whats the problem? you didnât change the value
i did change the value ill show you one second
It printed 0 meaning you didnât change the value
ok now it works when i changed the value
for some reason it didnt work the first time
I think because u didnt change it on server side
ok now it saves but for some reason when i sell the money at the shop it doesnt save?
You might have left to quickly
can u post videos here or not?
No idea this is my first day talking on the devforum
Did you add game:BindToClose() function??
where would i add that??? using more question marks to use limit of words
game.Players.PlayerRemoving:Connect(function(player)
Local data
local tableToSave = {}
for i,v in pairs(player.leaderstats:GetChildren())do
tableToSave[v.Name] = v.Value
end
local sucess, errormessage = pcall(function()
data = PlayerData:SetAsync(player.UserId,tableToSave)
end)
if sucess then
print("Data Successfully Saved!")
print(data)
else
print("Error Saving Data.")
warn(errormessage)
end
end)
game:BindToClose(function()
task.wait(3)
end)
There.this will give the game time to do something like saving data
also can I make it not save Backpack trash?
Yes just make a checking if value name is equal to trashbackpack then dont do anything ⌠example:
for i,v in pairs(player.leaderstats:GetChildren())do
If not v.Name == the desire name then
tableToSave[v.Name] = v.Value
end
end