REAL MouseEnter/MouseLeave for GuiObjects -- THEY ACTUALLY FIRE!

I have seen so many people face issues with GuiObject mouse events not firing, leaving their UI sad :frowning:

Sources

Extend MouseEnter/MouseLeave (GuiObject) to fire in more scenarios

GuiObject.MouseLeave not firing as expected [Only occurring with the input device being mouse]

.MouseEnter/.MouseLeave not fired on UI Frames when scrolled - #11 by 7eoeb

This only works with ScreenGuis, if you need reliable Mouse Events for SurfaceGui, click here

Showcase :video_camera:

Roblox’s MouseEvents (BAD)


My MouseEvents (GOOD)


Another Comparison

The main advantage: ScrollingFrames

The most common report is that it doesn’t fire when scrolling through frames. This is because the engine only checks wether the user is hovering over a GuiObject every time the mouse moves, not every frame. My version fixes this (shown in the first video).

Other advantages

  • No more issues where MouseLeave randomly doesn’t fire
  • Works with CoreGui open

How to use

Just require the module and call the .new() function, passing in the GuiObject. You’ll get two RBXScriptSignals (mouseEnter, mouseLeave).

Example code:

local ScrollingFrame = script.Parent
local MouseEvents = require(script.MouseEvents)

local TweenService = game:GetService("TweenService")
local info = TweenInfo.new(0.15)

for _, v in ScrollingFrame:GetChildren() do
	if v:IsA("ImageButton") then
		local enter, leave = MouseEvents.new(v)
		enter:Connect(function()
			TweenService:Create(v, info, {BackgroundColor3 = Color3.fromRGB(235, 235, 235)}):Play()
			TweenService:Create(v.UIStroke, info, {Thickness = 2}):Play()
		end)
		leave:Connect(function()
			TweenService:Create(v, info, {BackgroundColor3 = Color3.fromRGB(255, 255, 255)}):Play()
			TweenService:Create(v.UIStroke, info, {Thickness = 0}):Play()
		end)
	end
end

Real world example: robloxOS

A while ago I implemented this module into my own game, and want to link it here so you can see what it is like. Link: robloxOS


Links:

Module
Testing Place - Play
mouseEventsOctober52025.rbxl (94.4 KB)

You must leave the credit print statement. Thank you!

Have any bugs? Any issues? Not what you’re looking for?
Feel free to DM me or reply on this thread!

Reply with cool effects you’ve made :speech_balloon:

13 Likes

Both the native and custom setups in the showcase video appear to behave the same. Could you spot the difference? I couldn’t.

2 Likes

used this in my game just so i could remove the credit print statement

did you even read the post

5 Likes

I’m going to use this but I’m going to remove the credit warn function because I want to

3 Likes

no

sorry

||ihatethischaracterlimit||

2 Likes

Read the post please

The events are checked every frame

I attached 2 more videos at the top of the post. I feel like the original one wasn’t clear.

cough COUgh

Summary
Summary

no

2 Likes

:frowning: That makes me sad

Are you happy I’m sad that you’re not crediting?

1 Like

not everybody wants it to be there tbf, it might be annoying to have it + ur code is pretty much open source, they’re allowed to do whatever they want once released lol

4 Likes

Yeah haha. no, open source code? time to fork it and remove that! :3

jokes aside, I dont think anyone will do that.. genuinely most devs aim for clean and compact outputs, and literally 60% of people remove even the foreverHD credit for topbar plus.

1 Like

literally me too :laughing:

i dont really care about keeping it

So if you care about clean outputs why do u tell people:

feels weird.

Yeah, true.
But…

So you don’t actually need it. Not going to edit the post though