local I=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local F=I:WaitForChild("\099\111\109\109\111\110")local e=I:WaitForChild("\108\105\098")local k=require(F:WaitForChild("\065\099\116\105\111\110\115"))local c=k.PLAYER_ADD return function(I)return function(F)local k={portals={AbyssPortal=false};inventory={},stats={coins=0}}local t=k if game.PlaceId~=0 then local F=require(e:WaitForChild("\068\097\116\097\083\116\111\114\101\050"))local c=F("\115\097\118\101\068\097\116\097",I)local o=c:Get(nil)print(o)if o==nil then print("\078\111 \108\111\097\100\101\100\044 \103\111\105\110 \119\105\116\104 \100\101\102\097\117\108\116\033")t=k else t=o end end F:dispatch(c(I,t))print("\100\097\116\097 \108\111\097\100\101\100\046")end end
-- PLAYER_JOINED thunk
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local common = ReplicatedStorage:WaitForChild("common")
local lib = ReplicatedStorage:WaitForChild("lib")

local Actions = require(common:WaitForChild("Actions"))

local PLAYER_ADD = Actions.PLAYER_ADD

return function(player)
    return function(store)
        local defaultSave = {
            portals = {
                AbyssPortal = false
            },
            inventory = {
                -- default items should be given each time a player joins
                -- if they're just defined here then returning players
                -- will not retroactively get them.
            },
            stats = {
                coins = 0,
            }
        }
        local playerSaveTable = defaultSave
        if game.PlaceId ~= 0 then
            local DataStore2 = require(lib:WaitForChild("DataStore2"))

            -- load from datastore2
            local saveDataStore = DataStore2("saveData",player)
            local dataStore2SaveTable = saveDataStore:Get(nil)

            print(dataStore2SaveTable)

            if dataStore2SaveTable == nil then
                print("No loaded, goin with default!")
                playerSaveTable = defaultSave
            else
                playerSaveTable = dataStore2SaveTable
            end
        end

        store:dispatch(PLAYER_ADD(player, playerSaveTable))
        print(("data loaded."))
    end
end