local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore ("CashSaveSystem")
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 = ds:GetAsync(player.UserId) or 0 Cash.Changed:Connect(function() ds:SetAsync(player.UserId, Cash.Value)
end)
end)
game.Players.PlayerRemoving:Connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Money.Value) end)
Cash. Name = "Cash"
. Remove that space. However, you still have a problem! Your SetAsync
bit is saving player.leaderstats.Money.Value
! You named it Cash
! Change it to Cash
and it should work.local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem") game.Players.PlayerAdded:Connect(function(player) local leader = Instance.new("Folder") -- parent argument is deprecated leader.Name = "leaderstats" local Cash = Instance.new("IntValue") Cash.Name = "Cash" Cash.Value = ds:GetAsync(player.UserId) or 0 leader.Parent = player -- assign parent LAST not first Cash.Parent = leader end) game.Players.PlayerRemoving:Connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) end)