local ds = game:GetService("DataStoreService")
local cashDs = ds:GetDataStore("CashDataStore")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local cash = Instance.new("NumberValue", leaderstats)
cash.Name = "Cash"
cash.Parent = leaderstats
local data = cashDs:GetAsync(tostring(plr.UserId))
if data ~= nil then
cash.Value = data
cashDs:SetAsync(tostring(plr.UserId), cash.Value)
else
data = 0
cash.Value = data
cashDs:SetAsync(tostring(plr.UserId), cash.Value)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
cashDs:SetAsync(tostring(plr.UserId), plr.leaderstats.Cash.Value)
end)
It always gives 0 even when I increment it.
