How to check if a player has their mouse on a button

Hello!

How do you check if a player’s mouse is onto of a textbutton?
Is there a easy way? Checking if the mouse is at a specific coordinate is kinda hard and not so nice.

Maybe there is a very simple way for checking if the mouse is not clicking on a button but ontop of it.

Thanks for reading this and I hope u can help!

Textbuttons have an event called MouseEnter, which should do as you want, just sent it up as you want and when you hover your mouse over the Textbutton, will run the event

1 Like

Hopefully this helps.

[I am not really a good teacher]

1 Like

it only runs the event for some reason when I click the button.

MouseEnter is usually used for a sound effect when the mouse goes onto the GUI button.
[My opinion]

1 Like

Huh? What code are you using? MouseEnter only works when you move your mouse over a GuiObject

1 Like
script.Parent.MouseEnter:Connect(function()
 --code
end)
1 Like
script.Parent.MouseEnter:Connect(function()

print("Player entered textbox")

end)

inside of a localscript that is inside a textbutton

Huh? How does that only run when you click on it? Are you sure it’s that code? Do you have other localscripts for that same button?

1 Like

does mouse.Target work on guis

1 Like

Nope, it’s inside the correct button and it doesn’t run when my mouse is above the button. It only prints it out when I press it

I tested the code and for me It works fine. Maybe restart studio?

1 Like

Oops! I forgot that I was using the mobile emulator. maybe that has to do with it! It was just me being stupid.

1 Like

problem solved!!!

1 Like

Oh lol, thats probably the issue :laughing:

1 Like

The fact that the OP’s wish was fulfilled, does not make you answer the post correctly, checking if the mouse is on a button is a one-time operation, meanwhile “detecting” checks automatically, please answer the post correctly next time.