local DSS = game:GetService("DataStoreService")
local PlayerCash = DSS:GetDataStore("Tix")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Folder = Instance.new("Folder")
Folder.Name = "Data"
Folder.Parent = Player
local Cash = Instance.new("IntValue")
Cash.Name = "Tix"
Cash.Parent = Player.Data
Cash.Value = PlayerCash:GetAsync(Player.userId) or 0
game.Players.PlayerRemoving:connect(function(Player)
PlayerCash:SetAsync(Player.userId, Cash.Value)
end)
end)
end)
When I test out to see if it works, it doesn't save at all. If I change the intvalue, it changes. But when I stop studio to see if it worked and play it again. It sets back to zero.

5 comments
You're doing players removing inside of player added?
Am I supposed to put them in separate scripts?
No, just not inside of eachother.
So, you would take out the removing, and put it under the last end)
I mean it works its just that now theres an error saying "Value is not a valid member of GlobalDataStore."