local DataStoreService = game:GetService("DataStoreService") local myDataStore = DataStoreService:GetDataStore("myDataStore") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local Dollars = Instance.new("IntValue") Dollars.Name = "Dollars" Dollars.Parent = leaderstats local data local success, errormessage = pcall(function() data = myDataStore:GetAsync(player.userId.."-Dollars") end) if success then print("Your data has loaded") Dollars.Value = data else print("There was an error loading your data") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.userId.."-Dollars", player.leaderstats.dollars.Value) end) if success then print("Data successfully saved") else print("There was an error when saving player data") warn(errormessage) end end)