Mouse Enter and Mouse Leave workarounds?

Hello everyone, I was wondering how you guys did your Mouse enter and Mouse Leave workarounds. This has been a major problem that I always experience when working with GUI’s.

Currently I am making another GUI and am suffering with mouse enter and mouse leave glitching again and again, resulting to buttons being in wrong places and many other problems. That’s why I would like to know if there is a workaround to this, and if there is how will I be able to do it?

I’ve tried to do a loop but that won’t work for me since they take up way much more memory than needed.

2 Likes

In my experience, InputBegan and InputEnded seem to exhibit more consistent behavior, and all GuiObjects inherit these events, so the implementation is fairly simple. You just have to check if the input is related to the movement of the mouse.

Object.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseMovement then
		print("Mouse entered")
	end
end)

Object.InputEnded:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseMovement then
		print("Mouse left")
	end
end)
10 Likes