Hello. I am experiencing so, so, so much difficulty with the datasave and the data just does not save what so ever! SCRIPT:
game:BindToClose(function() wait(30) end) local DataStore = game:GetService("DataStoreService"):GetDataStore("MainCarDataStore") local autosavex = 60 local playerRemoved = false game.Players.PlayerAdded:Connect(function(plr) wait(1) local CamaroOwned = Instance.new('BoolValue',plr) CamaroOwned.Name = "CamaroSSOwned" local LamOwned = Instance.new('BoolValue',plr) LamOwned.Name = "LamborghiniOwned" local Audi4Owned = Instance.new("BoolValue",plr) Audi4Owned.Name = "AudiA4Owned" local One1Owned = Instance.new("BoolValue",plr) One1Owned.Name = "One1Owned" local LamHurAc = Instance.new("BoolValue",plr) LamHurAc.Name = "LamborghiniHuracanAccess" local Fiat500Own = Instance.new("BoolValue",plr) Fiat500Own.Name = "Fiat500Owned" local TeslaMSOwn = Instance.new("BoolValue",plr) TeslaMSOwn.Name = "TeslaModelSOwned" local AudiTTRoadOwn = Instance.new("BoolValue",plr) AudiTTRoadOwn.Name = "AudiTTRoadsterOwned" local NissanGTROwn = Instance.new("BoolValue",plr) NissanGTROwn.Name = "NissanGTROwned" local AudiR8Own = Instance.new("BoolValue",plr) AudiR8Own.Name = "AudiR8Owned" local BugattiVeyOwn = Instance.new("BoolValue",plr) BugattiVeyOwn.Name = "BugattiVeyronOwned" local Porsche911Own = Instance.new("BoolValue",plr) Porsche911Own.Name = "Porsche911Owned" local FordTransitOwn = Instance.new("BoolValue",plr) FordTransitOwn.Name = "FordTransitVanOwned" local AudiS5Own = Instance.new("BoolValue",plr) AudiS5Own.Name = "AudiS5Owned" local JaguarModded = Instance.new("BoolValue",plr) JaguarModded.Name = "JaguarXJ6ModdedOwned" local ID = "CarsOwned-"..plr.UserId local savedData = nil pcall(function() savedData = DataStore:GetAsync(ID) end) if savedData ~= nil then CamaroOwned.Value = savedData[1] LamOwned.Value = savedData[2] Audi4Owned.Value = savedData[3] One1Owned.Value = savedData[4] LamHurAc.Value = savedData[5] Fiat500Own.Value = savedData[6] TeslaMSOwn.Value = savedData[7] AudiTTRoadOwn.Value = savedData[8] NissanGTROwn.Value = savedData[9] AudiR8Own.Value = savedData[10] BugattiVeyOwn.Value = savedData[11] Porsche911Own.Value = savedData[12] FordTransitOwn.Value = savedData[13] AudiS5Own.Value = savedData[14] print("Data Loaded for") end local playerRemoved = false local function autoSave(plr) while playerRemoved == false do wait(60) local ID = "CarsOwned-"..plr.UserId local ValuesToSave = { plr.CamaroSSOwned.Value, plr.LamborghiniOwned.Value, plr.AudiA4Owned.Value, plr.One1Owned.Value, plr.LamborghiniHuracanAccess.Value, plr.Fiat500Owned.Value, plr.TeslaModelSOwned.Value, plr.AudiTTRoadsterOwned.Value, plr.NissanGTROwned.Value, plr.AudiR8Owned.Value, plr.BugattiVeyronOwned.Value, plr.Porsche911Owned.Value, plr.FordTransitVanOwned.Value, plr.AudiS5Owned.Value } DataStore:SetAsync(ID, ValuesToSave) print("data saved for"..plr.UserId) end end end) game.Players.PlayerRemoving:Connect(function(player) playerRemoved = true end) game:BindToClose(function() for i, player in pairs(game.Players:GetPlayers()) do if player then player:Kick("This game is shutting down") end end end)
Seriously i need so much help with this i have been trying for ages now to complete this. I have tried using player removing to save and that does not work at all. Please help! All help is appreciated!
As I said to the last person asking about it, it might be complicated by Instance.new. Try another method to creating it or just do it without an instance, just create it in a folder, cause you are always inserting the new value and when you rejoin, it inserts new instead of saving last one. Hope it helped!