Yo, so I've made a bool value inside leaderstats script that I copied from a tutorial. The Bool Value says whether or not a player owns a vehicle. I have two values, Money and the Vehicle. The vehicle saves, however the money does not. Any help is appreciated.
Error: DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = Money-226030996
local currencyName = "Money"
local Car1Owned = "Car1Owned"
local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local currency = Instance.new("IntValue")
currency.Name = currencyName
currency.Parent = folder
local Owned = Instance.new("BoolValue")
Owned.Name = Car1Owned
Owned.Parent = folder
local ID = currencyName.."-"..player.UserId
local savedData = nil
pcall(function()
savedData = DataStore:GetAsync(ID)
end)
if savedData ~= nil then
Owned.Value = savedData
currency.Value = savedData
print("Data loaded")
else
-- new player
currency.Value = 1000
print("New player to the game")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local ID = currencyName.."-"..player.UserId
DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
DataStore:SetAsync(ID,player.leaderstats[Car1Owned].Value)
end)

1 comment
You’re overwriting it