So i have made this script thats suposed to save the players Cash and the vehicles it has purchased, tho for some reason the vehicles purchased dont get saved only the Cashvalue.
Script:
local DataStore = game:GetService("DataStoreService") local ds1 = DataStore:GetDataStore("RTPD")
game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder", player) leader.Name = "leaderstats"
local Cash = Instance.new("IntValue", leader)
Cash.Name = "Cash"
Cash.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, Cash.Value)
game.StarterGui.PurchaseGUI.Frame.Zilko_Natalia.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Voyage_D.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.DA_Ferra.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.DA_Venerra.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Hektor_Mediona.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Mounts_Rake.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Novena_Acesera.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Roland_Motors_GTR.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Surge_Maple_R.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Voyage_Jalanster_Betamobili.Purchased.Value = ds1:GetAsync(player.UserId) or false
game.StarterGui.PurchaseGUI.Frame.Voyage_Pengangkuter_30_CWT.Purchased.Value = ds1:GetAsync(player.UserId) or false
wait(5)
--Cash.Changed:connect(function()
print("SavingData")
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Zilko_Natalia.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Voyage_D.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.DA_Ferra.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.DA_Venerra.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Hektor_Mediona.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Mounts_Rake.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Novena_Acesera.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Roland_Motors_GTR.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Surge_Maple_R.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Voyage_Jalanster_Betamobili.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Voyage_Pengangkuter_30_CWT.Purchased.Value)
ds1:SetAsync(player.UserId, Cash.Value)
end)
--end)
game.Players.PlayerRemoving:connect(function(player) ds1:setAsync(player.UserId, player.leaderstats.Cash.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Zilko_Natalia.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Voyage_D.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.DA_Ferra.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.DA_Venerra.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Hektor_Mediona.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Mounts_Rake.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Novena_Acesera.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Roland_Motors_GTR.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Surge_Maple_R.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Voyage_Jalanster_Betamobili.Purchased.Value)
ds1:SetAsync(game.StarterGui.PurchaseGUI.Frame.Voyage_Pengangkuter_30_CWT.Purchased.Value)
end)

2 comments
Any errors?
there are no errors