local function playerAdded(player)
local success, data = pcall(function ()
return CardStore:GetAsync(player.UserId)
end)
if success then
if data then
CardCache[player.UserId] = data
MatchService.TemporaryCache[player.UserId] = {CardCache[player.UserId]}
else
CardCache[player.UserId] = createDefaultDeck()
MatchService.TemporaryCache[player.UserId] = {CardCache[player.UserId]}
end
else
-- Handle case of error; kick, block saving, etc.
warn(string.format("Could not load data for %s: %s", player.Name, data))
end
print(MatchService.TemporaryCache)
for _, card in pairs(CardCache[player.UserId]) do
--nothing here yet
end
CardService.CardCache = CardCache
end
Players.PlayerAdded:Connect(playerAdded)
Ok, I’m back on PC. Lua is not like low level languages where you can specify whether the variable is a pointer or not, so it’s good to know what will be passed by reference and what will be passed by value.