Hello. I have a problem with my DataSave Script saving two values one for the leaderboard and one for the player (Money and PlaxtonOwned). This DataSave script is vital for one time purchases to work on Bus Simulator. Here is the datasave script:
local dataStoreService = game:GetService("DataStoreService"):GetDataStore("MoneyDataStore") game.Players.PlayerAdded:connect(function(plr) local key = 'id-'..plr.userId local stats = Instance.new('IntValue',plr) stats.Name = "leaderstats" local money = Instance.new('IntValue',stats) money.Name = "Money" local vehStats = Instance.new('IntValue',plr) vehStats.Name = "vehStats" local PlaxtonOwned = Instance.new('IntValue',vehStats) PlaxtonOwned.Name = "PlaxtonOwned" local getSavedData = dataStoreService:GetAsync(key) if getSavedData then money.Value = getSavedData[1] PlaxtonOwned.Value = getSavedData[2] else local saving = {money.Value, PlaxtonOwned.Value} dataStoreService:SetAsync(key,saving) end end) game.Players.PlayerRemoving:connect(function(plr) local key = 'id-'..plr.userId local save = {plr.leaderstats.Money.Value, plr.vehStats.PlaxtonOwned.Value} dataStoreService:SetAsync(key,save) end)
As you can see it saves two values but when i go on the game and my money goes down from 400000 to 391000 however i play my game for 10 minutes and i rejoin to see if the data had been saved but it is still on 400000 and the plaxtonowned value is not saved. I really need help with this i have been trying since last weekend trying to make this work. Please help!
If you're testing off of play on Roblox Studio, it doesn't save. Check the Developer Console for any errors.