local D={}D.__index=D function D.Connect(D)D.connection=D.signal.event:Connect(function()D.func(table.unpack(D.signal.arguments))end)D.Connected=true end function D.Disconnect(D)if D.connection then D.connection:Disconnect()D.Connected=false end end function D.destroy(D)D:Disconnect()end function D.new(p,n)local I={}setmetatable(I,D)I.connection=nil I.signal=p I.func=n I.Connected=false I:Connect()return I end return D
-- OptimisticSide
-- 5/7/2021
-- Signal connection that mimics an RBXScriptConnection

local Connection = {}
Connection.__index = Connection

-- Connect the connection to its signal.
function Connection:Connect()
	self.connection = self.signal.event:Connect(function()
		self.func(table.unpack(self.signal.arguments))
	end)
	self.Connected = true
end

-- Disconnect the connection from its signal.
function Connection:Disconnect()
	if self.connection then
		self.connection:Disconnect()
		self.Connected = false
	end
end

-- Distroys the signal.
function Connection:destroy()
	self:Disconnect()
end

-- Create a connection object.
function Connection.new(signal, func)
	local self = {}
	setmetatable(self, Connection)

	self.connection = nil
	self.signal = signal
	self.func = func

	self.Connected = false
	self:Connect()
	return self
end

return Connection
