--Public functions


local module = {}

function module.MouseEnterLeaveEvent(UIObj)
	if CurrentItems[UIObj] then
		return CurrentItems[UIObj].EnteredEvent.Event,CurrentItems[UIObj].LeaveEvent.Event
	end     

	local newObj = {}

	newObj.UIObj = UIObj

	local EnterEvent = Instance.new("BindableEvent")
	local LeaveEvent = Instance.new("BindableEvent")

	newObj.EnteredEvent = EnterEvent
	newObj.LeaveEvent = LeaveEvent
	newObj.MouseWasIn = false
	CurrentItems[UIObj] = newObj

	UIObj.AncestryChanged:Connect(function()
		if not UIObj.Parent then
			--Assuming the object has been destroyed as we still dont have a .Destroyed event
			--If for some reason you parent your UI elements to nil after calling this, then parent it back again, mouse over will still have been disconnected.
			EnterEvent:Destroy()    
			LeaveEvent:Destroy()    
			CurrentItems[UIObj] = nil
		end
	end)

	return EnterEvent.Event,LeaveEvent.Event
end

return module
