local M={}M.__index=M M.Service=nil function M.new()local V=M.Service or{}setmetatable(V,M)V.BindedPlayerAddedFunctions={}V.BindedCharacterAddedFunctions={}V.BindedPlayerRemovingFunctions={}for M,h in pairs(game.Players:GetPlayers())do V:PlayerAdded(h)end V.Connections={PlayerAdded=game.Players.PlayerAdded:Connect(function(M)V:PlayerAdded(M)end),PlayerRemoving=game.Players.PlayerRemoving:Connect(function(M)V:PlayerRemoving(M)end)}M.Service=V return V end function M.PlayerAdded(V,M)for V,h in pairs(V.BindedPlayerAddedFunctions)do h(M)end if M.Character then V:CharacterAdded(M.Character)end M.CharacterAdded:Connect(function(M)V:CharacterAdded(M)end)end function M.PlayerRemoving(V,M)for V,h in pairs(V.BindedPlayerRemovingFunctions)do h(M)end end function M.CharacterAdded(V,M)for V,h in pairs(V.BindedCharacterAddedFunctions)do h(M)end end function M.AddPlayerAddedFunc(h,M,V)h.BindedPlayerAddedFunctions[M]=V for M,h in pairs(game.Players:GetPlayers())do warn(h.Name.." \119\097\115 \097\108\114\101\097\100\121 \105\110 \116\104\101 \103\097\109\101 \098\101\102\111\114\101 \119\101 \097\100\100\101\100 \116\104\105\115 \112\108\097\121\101\114 \097\100\100\101\100 \102\117\110\099\116\105\111\110")V(h)end end function M.AddPlayerRemovingFunc(h,M,V)h.BindedPlayerRemovingFunctions[M]=V end function M.AddCharacterAddedFunc(h,M,V)h.BindedCharacterAddedFunctions[M]=V for M,h in pairs(game.Players:GetPlayers())do if h.Character then warn(h.Name.." \119\097\115 \097\108\114\101\097\100\121 \105\110 \116\104\101 \103\097\109\101 \098\101\102\111\114\101 \119\101 \097\100\100\101\100 \116\104\105\115 \067\104\097\114\097\099\116\101\114 \097\100\100\101\100 \102\117\110\099\116\105\111\110")V(h.Character)end end end function M.Deconstruct(M) end return M
--[[
	PlayerServer.lua

	AddPlayerAddedFunc:
		Add a function that runs whenever a player joins a server

]]

local this = {}
this.__index = this

this.Service = nil

function this.new()
	-- body
	local self = this.Service or {}
	setmetatable(self, this)

	self.BindedPlayerAddedFunctions = {}
	self.BindedCharacterAddedFunctions = {}
	self.BindedPlayerRemovingFunctions = {}

	for _, v in pairs(game.Players:GetPlayers()) do
		self:PlayerAdded(v)
	end
	self.Connections = {
		PlayerAdded = game.Players.PlayerAdded:Connect(function(plr)
			self:PlayerAdded(plr)
		end),
		PlayerRemoving = game.Players.PlayerRemoving:Connect(function(plr)
			self:PlayerRemoving(plr)
		end),
	}

	this.Service = self
	return self
end

function this:PlayerAdded(plr)
	for _, v in pairs(self.BindedPlayerAddedFunctions) do
		v(plr)
	end
	if plr.Character then
		self:CharacterAdded(plr.Character)
	end
	plr.CharacterAdded:Connect(function(char)
		self:CharacterAdded(char)
	end)
end

function this:PlayerRemoving(plr)
	for _, v in pairs(self.BindedPlayerRemovingFunctions) do
		v(plr)
	end
end

function this:CharacterAdded(char)
	for _, v in pairs(self.BindedCharacterAddedFunctions) do
		v(char)
	end
end

function this:AddPlayerAddedFunc(name, func)
	-- body
	self.BindedPlayerAddedFunctions[name] = func
	for i, v in pairs(game.Players:GetPlayers()) do
		warn(v.Name .. " was already in the game before we added this player added function")
		func(v)
	end
end

function this:AddPlayerRemovingFunc(name, func)
	-- body
	self.BindedPlayerRemovingFunctions[name] = func
end

function this:AddCharacterAddedFunc(name, func)
	-- body
	self.BindedCharacterAddedFunctions[name] = func
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Character then
			warn(v.Name .. " was already in the game before we added this Character added function")
			func(v.Character)
		end
	end
end

function this:Deconstruct() -- Delete the player's object
end

return this
