function t.CreateSignal()local j={}local H=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")local p={}function j.Connect(A,e)if A~=j then error("\099\111\110\110\101\099\116 \109\117\115\116 \098\101 \099\097\108\108\101\100 \119\105\116\104 \096\058\096\044 \110\111\116 \096\046\096",2)end if type(e)~="\102\117\110\099\116\105\111\110"then error("\065\114\103\117\109\101\110\116 \035\049 \111\102 \099\111\110\110\101\099\116 \109\117\115\116 \098\101 \097 \102\117\110\099\116\105\111\110\044 \103\111\116 \097 "..type(e),2)end local M=H.Event:Connect(e)p[M]=true local G={}function G.disconnect(j)M:Disconnect()p[M]=nil end G.Disconnect=G.disconnect return G end function j.disconnect(H)if H~=j then error("\100\105\115\099\111\110\110\101\099\116 \109\117\115\116 \098\101 \099\097\108\108\101\100 \119\105\116\104 \096\058\096\044 \110\111\116 \096\046\096",2)end for j,H in pairs(p)do j:Disconnect()p[j]=nil end end function j.wait(p)if p~=j then error("\119\097\105\116 \109\117\115\116 \098\101 \099\097\108\108\101\100 \119\105\116\104 \096\058\096\044 \110\111\116 \096\046\096",2)end return H.Event:Wait()end function j.fire(p,...)if p~=j then error("\102\105\114\101 \109\117\115\116 \098\101 \099\097\108\108\101\100 \119\105\116\104 \096\058\096\044 \110\111\116 \096\046\096",2)end H:Fire(...)end j.Connect=j.connect j.Disconnect=j.disconnect j.Wait=j.wait j.Fire=j.fire return j end


function t.CreateSignal()
	local this = {}

	local mBindableEvent = Instance.new('BindableEvent')
	local mAllCns = {} --all connection objects returned by mBindableEvent::connect

	--main functions
	function this:Connect(func)
		if self ~= this then error("connect must be called with `:`, not `.`", 2) end
		if type(func) ~= 'function' then
			error("Argument #1 of connect must be a function, got a "..type(func), 2)
		end
		local cn = mBindableEvent.Event:Connect(func)
		mAllCns[cn] = true
		local pubCn = {}
		function pubCn:disconnect()
			cn:Disconnect()
			mAllCns[cn] = nil
		end
		pubCn.Disconnect = pubCn.disconnect
		
		return pubCn
	end
	
	function this:disconnect()
		if self ~= this then error("disconnect must be called with `:`, not `.`", 2) end
		for cn, _ in pairs(mAllCns) do
			cn:Disconnect()
			mAllCns[cn] = nil
		end
	end
	
	function this:wait()
		if self ~= this then error("wait must be called with `:`, not `.`", 2) end
		return mBindableEvent.Event:Wait()
	end
	
	function this:fire(...)
		if self ~= this then error("fire must be called with `:`, not `.`", 2) end
		mBindableEvent:Fire(...)
	end
	
	this.Connect = this.connect
	this.Disconnect = this.disconnect
	this.Wait = this.wait
	this.Fire = this.fire

	return this
end
