PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Mouse Hovering On and Off of a ClickDetector

Mouse Hovering On and Off of a ClickDetector

Oct 01 2018, 1:30 AM PST

The below code will print “Oh my… PlayerName left the confines of my parent” when a player’s mouse is moved off of the ClickDetector|ClickDetector's parent, replacing “PlayerName” with the player’s name.

It will also print “Oh my… PlayerName hovered over my parent” when a player’s mouse hovers over the ClickDetector’s parent, replacing “PlayerName” with the player’s name.

In order for this example to work as expected, it must be placed in a Script or LocalScript whose parent is the ClickDetector.

script.Parent.ClickDetector.MouseHoverLeave:Connect(function(Player)
   print("Oh my... " .. Player.Name .. " left the confines of my parent")
end)

script.Parent.ClickDetector.MouseHoverEnter:Connect(function(Player)
   print("Oh my... " .. Player.Name .. " hovered over my parent")
end)