Gives me an error with "ServerScriptService.DataStore:33: attempt to index number with 'cash'
local DataStoreService = game:GetService("DataStoreService")
local cashStore = DataStoreService:GetDataStore("PlayerCash")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Parent = leaderstats
local Wins = Instance.new("IntValue")
Cash.Name = "Wins"
Cash.Parent = leaderstats
local playerUserId = player.UserId
local data
local succ, err = pcall(function()
data = cashStore:GetAsync("Player_"..playerUserId)
end)
if succ then
Cash.Value = data.cash
Wins.Value = data.wins
elseif err then
print(err)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = player.UserId
local storedIntegers = {
cash = player.leaderstats.Cash.Value;
wins = player.leaderstats.Wins.Value;
}
local succ, succ = pcall(function()
cashStore:SetAsync("Player_"..playerUserId,storedIntegers)
end)
end)

2 comments
I think you have to put Cash.Value = data.Cash Wins.Value = data.Wins instead of Cash.Value = data.cash Wins.Value = data.wins but i'm not sure
False, i have two variables inside the table that are called "cash", "wins", which i'm trying to access from when the pcall is called success.