local p={}p.__index=p function p.new()return setmetatable({_listeners={}},p)end function p.Connect(m,p)table.insert(m._listeners,p)return{Disconnect=function()for O=#m._listeners,1,-1 do if m._listeners[O]==p then table.remove(m._listeners,O)break end end end}end function p.Fire(p,...)for p,m in ipairs(p._listeners)do m(...)end end return p
--[[
	A signal that calls listeners synchronously.
]]

local Signal = {}
Signal.__index = Signal

function Signal.new()
	return setmetatable({
		_listeners = {},
	}, Signal)
end

function Signal:Connect(listener)
	table.insert(self._listeners, listener)

	return {
		Disconnect = function()
			for i = #self._listeners, 1, -1 do
				if self._listeners[i] == listener then
					table.remove(self._listeners, i)
					break
				end
			end
		end,
	}
end

function Signal:Fire(...)
	for _, listener in ipairs(self._listeners) do
		listener(...)
	end
end

return Signal