Hover tooltip can easily go wrong

This is the function I use to show a tool tip when hovering over an item. The problem is all my items are really packed together (2 pixels gap between each) so when you leave one slot and into the next, it can sometimes fire the Start function before the leave function, thus causing the tool tip to disappear

function Hover.Start(slot, input)
	if slot.Container.Item.Value == "" then return end
	
	SetupBox(slot)
	
	HoverBox.Position = UDim2.new(0, Mouse.X + 20, 0, Mouse.Y + 40)
	
	HoverBox.Visible = true
end

function Hover.Stop(input)	
	if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
	
	-- Set invisible
	HoverBox.Visible = false
end
slot.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseMovement then
		Hover.Start(slot, input)
	end
end)	

slot.InputEnded:Connect(Hover.Stop)


I also tried putting a wait() at the start of the Start function, however that can still cause problems, where if I quickly pass through all the slots and out then out, the tool tip stays

You could have a variable that keeps track of which thing most recently caused the tooltip to appear. Hover.Stop should then be passed the slot as a parameter, and check to see if the thing that stopped being hovered is the same thing that most recently began being hovered. If it is, it should hide the tooltip. If not, just ignore the request.

1 Like