Fed up with MouseEnter and MouseLeave not working? Here's a module for you!

Quite right, changed it to heartbeat

1 Like

Characters are context dependent more than anything. There are a limited amount of character operations appropriate for RenderStepped; a majority of them aren’t.

That goes without saying. Things like animations should be tied to renderstepped.

Not necessarily, no. There is a lot of inappropriate usage of RenderStepped around, so I wouldn’t say that it “goes without saying”.

I would file animations under Stepped which runs before physics simulation. RenderStepped is more for things that you would realistically need done before a frame renders or the next render tick is executed, such as Camera movement.

RenderStepped is mostly for things that you’d need running at the same time as camera updates. Animations running at the same tick as the camera is not needed. If you want to do that though, feel free I suppose.

3 Likes

I was having issues with InputBegan and InputEnded, they usually work for me, so I thought the issue was that I was doing something wrong, but I decided to test this module to see if it solved the problem, and it did

work’s great for my inventory hovering

8 Likes

it’s good that you made this because MouseEnter and MouseLeave are literal trash and are not precise, thank you for sharing this with us! :grin:

2 Likes

This is a really good module, however with ScrollingFrames it still selects them when they are scrolled past. Do you think you could fix that?

1 Like

Hands down the best module for someone who knows only about half of scripting but a lot about UI. This helps me a lot for commissions and pretty much anything. Thank you so much for making this!

1 Like

It doesn’t seem to be working for me, any clue what I’m doing wrong? I’ve got the module location defined correctly, and the code is in a server script. I’ve tried it in a local script as well.

local MouseOverModule = require(game.ServerScriptService.MouseOverModule)

local MouseEnter, MouseLeave = MouseOverModule.MouseEnterLeaveEvent(script.Parent.AnimationTrigger)

script.Parent.AnimationTrigger.MouseEnter:Connect(function()
print("Mouse enter")
end)

script.Parent.AnimationTrigger.MouseLeave:Connect(function()
print("Mouse leave")
end)

Hello!

You must use the variables instead

local MouseOverModule = require(game.ServerScriptService.MouseOverModule)

local MouseEnter, MouseLeave = MouseOverModule.MouseEnterLeaveEvent(script.Parent.AnimationTrigger)

MouseEnter:Connect(function()
print(“Mouse enter”)
end)

MouseLeave:Connect(function()
print(“Mouse leave”)
end)

(I posted this on mobile sorry for the bad formatting)

1 Like

It still doesn’t work for me. I’ve tried it in both a server script and a local script. There’s nothing about an error in the output either. What else could I do to fix it?

What if you don’t want to delete it. Will it always work on the Gui?

Seems to not be working as expected!
image
Expected to have print 2, however only get 1:
image
Seems to be a problem with the module, idk

Dude, you’re high, those are different errors lol, read where the error lines are.

6 Likes

Hey!! im having a problem where the event fires even if the guiObject’s visible is set to false, which means that it has been entered/left, do you know how to fix that?

here’s a video of what’s happening

https://gyazo.com/d2d17ffbef8c6636fd9eec54a7b727dd

this is how i used it

runService.RenderStepped:Connect(function()
		textLabel.Parent.Position = UDim2.new(0,mouse.X,0,mouse.Y) --frame follow mouse
	
		for _, gui in pairs(playerGui.dressUpGui:GetDescendants()) do
			if gui:FindFirstChild("item") or gui:FindFirstChild("face") and then
				
				local MouseEnter, MouseLeave = mouseEnterLeaveModule.MouseEnterLeaveEvent(gui)
				
				MouseEnter:Connect(function()
					tweenIn(gui, textLabel)
				end)

				MouseLeave:Connect(function()
					tweenOut(gui, textLabel)
				end)
				
				gui.MouseButton1Click:Connect(function()
					tweenOut(gui, textLabel)
				end)
			end
		end
	end)

Why are you running this in a RenderStepped?

I was originally using GetGuiObjectAtPosition

should it be like that then?:

runService.RenderStepped:Connect(function()
		textLabel.Parent.Position = UDim2.new(0,mouse.X,0,mouse.Y)
end)
	
for _, gui in pairs(playerGui.dressUpGui:GetDescendants()) do
	if gui:FindFirstChild("item") or gui:FindFirstChild("face") then

		local MouseEnter, MouseLeave = mouseEnterLeaveModule.MouseEnterLeaveEvent(gui)

		MouseEnter:Connect(function()
			tweenIn(gui, textLabel)
		end)

		MouseLeave:Connect(function()
			tweenOut(gui, textLabel)
		end)

		gui.MouseButton1Click:Connect(function()
			tweenOut(gui, textLabel)
		end)
	end
end

Well for now I’ve realized that MouseEnter and leave work pretty decent on their own and stopped trying to fix them.

1 Like

I’m new to scripting and i was hoping someone could tell me how i should use the scripts above, thanks!

This is exactly what I was looking for. Thank you @madattak! My inventory system needed this. Definitely saved me the frustration and development time, great work on this.

1 Like