local D=game:GetService("\080\108\097\121\101\114\115")local p=script.Parent local n=require(p.Core.Remote)local I=n.getManager()local b=I.getModule("\076\111\103\103\101\114")local F=I.getModule("\083\105\103\110\097\108")local L={}function L.handleJoin(D)L.userAdded:Fire(D)b.writeLog(b.joinLogs,{player=D})print(b.joinLogs)L.userLoaded:Fire(D)end function L.handleLeave(D)L.userLeaving:Fire(D)b.writeLog(b.leaveLogs,{player=D})end function L.init()D.PlayerAdded:Connect(L.handleJoin)D.PlayerRemoving:Connect(L.handleLeave)print("\104\105")for D,p in ipairs(D:GetPlayers())do L.handleJoin(p)end L.userAdded=F.new()L.userLoaded=F.new()L.userLeaving=F.new()end return L
-- OptimisticSide
-- 5/8/2021
-- Player handler

local Players = game:GetService("Players")

local server = script.Parent
local Remote = require(server.Core.Remote)

local Manager = Remote.getManager()

local Logger = Manager.getModule("Logger")
local Signal = Manager.getModule("Signal")

local Users = {}

-- Called upon a player joining.
function Users.handleJoin(player)
	Users.userAdded:Fire(player)
	Logger.writeLog(Logger.joinLogs, { player = player })
print(Logger.joinLogs)
	Users.userLoaded:Fire(player)
end

-- Called upon a player leaving.
function Users.handleLeave(player)
	Users.userLeaving:Fire(player)
	Logger.writeLog(Logger.leaveLogs, { player = player })
end

-- Starts listening for players
-- joining and leaving.
function Users.init()
	Players.PlayerAdded:Connect(Users.handleJoin)
	Players.PlayerRemoving:Connect(Users.handleLeave)
print('hi')
	-- Set up any existing players.
	for _, player in ipairs(Players:GetPlayers()) do
		Users.handleJoin(player)
	end

	Users.userAdded = Signal.new()
	Users.userLoaded = Signal.new()
	Users.userLeaving = Signal.new()
end

return Users
