Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make gui elements react to the position of the player's mouse?

Asked by 4 years ago

I'm making a gui, and I want an image to spin when you highlight the frame that contains it with your mouse. I am pretty much completely lost here. All I need to know is how to detect when the mouse is hovering over a frame. Any help is appreciated, thanks!

P.S. Sorry for the lack of a script to work with :\

2 answers

Log in to vote
0
Answered by
sheepposu 561 Moderation Voter
4 years ago
Edited 4 years ago

To detect of the mouse is hovering over the frame do this

local mouse = game.Players.LocalPlayer:GetMouse()
local GUI = --get GUI Object

local Hover()
    if mouse.X >= GUI.X.Scale and mouse.X <= GUI.X.Scale + GUI.Size.X.Scale and mouse.Y >= GUI.Y.Scale and mouse.Y <= GUI.Y.Scale + GUI.Size.Y.Scale then
        return true
    else
        return false
end

I've never done this before but I looked up a few things and this should work

Ad
Log in to vote
0
Answered by 4 years ago

These forums have what you are looking for.

https://devforum.roblox.com/t/know-whatever-gui-the-mouse-is-hovering/269656/2

https://developer.roblox.com/en-us/api-reference/function/BasePlayerGui/GetGuiObjectsAtPosition

You get the list of GUIs, check if it is a certain one, then you apply the effects.

Answer this question