local s={}s.__index=s function s.new()local Q=setmetatable({_listeners={},_locked=false},s)Q.Event=Q return Q end function s.Connect(Q,s)table.insert(Q._listeners,s)return{Disconnect=function()local a=table.find(Q._listeners,s)if a then table.remove(Q._listeners,a)end end}end function s.Fire(s,...)if s._locked then error("\067\097\110\110\111\116 \102\105\114\101 \119\104\105\108\101 \102\105\114\105\110\103")end s._locked=true for s,Q in s._listeners do local a,i=pcall(Q,...)if not a then warn(i)end end s._locked=false end return s
local BindableEvent = {}
BindableEvent.__index = BindableEvent

function BindableEvent.new()
	local self = setmetatable({
		_listeners = {},
		_locked = false,
	}, BindableEvent)

	self.Event = self

	return self
end

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

	return {
		Disconnect = function()
			local index = table.find(self._listeners, listener)

			if index then
				table.remove(self._listeners, index)
			end
		end,
	}
end

function BindableEvent:Fire(...)
	if self._locked then
		error("Cannot fire while firing")
	end

	self._locked = true
	for _, listener in self._listeners do
		local ok, errors = pcall(listener, ...)

		if not ok then
			warn(errors)
		end
	end
	self._locked = false
end

return BindableEvent
