Below is my code. Code was working flawlessly but then all of a sudden it defaults the cash to $25 and doesn't save when exiting the game. No changes since I had created the script.
--// Datastore for Money \\-- --// Variables \\-- local DataStoreService = game:GetService("DataStoreService"):GetDataStore("MoneyDS") local plr_data --// Code \\-- game.Players.PlayerAdded:Connect(function(plr) --// Variables \\-- local dataStats = Instance.new("Folder") local Money = Instance.new("IntValue") local moneyEveryClick = Instance.new("IntValue") local newMEC = 25 local newCash = 10000 --// Code \\-- dataStats.Parent = plr dataStats.Name = "dataStats" Money.Parent = plr.dataStats Money.Name = "Money" Money.Value = 0 moneyEveryClick.Parent = plr.dataStats moneyEveryClick.Name = "moneyEveryClick" moneyEveryClick.Value = 0 local success, err = pcall(function() plr_data = DataStoreService:GetAsync(plr.UserId.."-Money") plr_data = DataStoreService:GetAsync(plr.UserId.."-moneyEveryClick") end) if plr_data ~= nil then Money.Value = plr_data moneyEveryClick.Value = plr_data else Money.Value = newCash moneyEveryClick.Value = newMEC end if success then print("Success!") return success end if err then print("Error: "..err) return err end end) game.Players.PlayerRemoving:Connect(function(plr) local success, err = pcall(function() DataStoreService:SetAsync(plr.UserId.."-Money",plr.dataStats.Money.Value) DataStoreService:SetAsync(plr.UserId.."-moneyEveryClick",plr.dataStats.moneyEveryClick.Value) end) if success then print("Success!") return success end if err then print("Error: "..err) return err end end) print("DataStore loaded.")