Is there a way to check if a frame has a mouse over?

I don’t want to trigger via event, more I want to check if a mouse is still hovering. Is there a way to compare that, or should I just make a variable to store the status?

MouseEntered event can be used on a button, not sure if the same can be used for frames

(as far as I’m aware) there’s no function to directly check if a mouse is currently hovering over a frame without the .MouseEnter & .MouseLeave events, but you could check if the mouse position is within the position & size bounds of the UI –

local frame = script.Parent -- assign your frame here
local mouse = game.Players.LocalPlayer:GetMouse()
local absolutePosition = frame.AbsolutePosition
local absoluteSize = frame.AbsoluteSize

local isInBounds = function()
    local xBound = (mouse.X >= absolutePosition.X and mouse.X < absolutePosition.X + absoluteSize.X)
    local yBound = (mouse.Y >= absolutePosition.Y and mouse.Y < absolutePosition.Y + absoluteSize.Y)
    return (xBound and yBound)
end
4 Likes