-- Get the mouse's current position
local mousePosition = UserInputService:GetMouseLocation()
local framePosition = self.frame.AbsolutePosition
local frameSize = self.frame.AbsoluteSize
-- Check if the mouse is still inside the frame
if mousePosition.X >= framePosition.X and mousePosition.X <= framePosition.X + frameSize.X and
mousePosition.Y >= framePosition.Y and mousePosition.Y <= framePosition.Y + frameSize.Y then
-- Mouse is still within the frame bounds, don't hide the popUp
return
end
I tried that, but I’m not sure if my logic is correct.
local Frame = script.Parent
local LocalPlayer = game.Players.LocalPlayer
local function Hovering()
local MousePos = game:GetService("UserInputService"):GetMouseLocation() - game:GetService("GuiService"):GetGuiInset()
local Guis = LocalPlayer:WaitForChild("PlayerGui"):GetGuiObjectsAtPosition(MousePos.X, MousePos.Y)
for _, Gui in Guis do
if Gui == Frame then
return true
end
end
return false
end
if Hovering() then
-- do stuff
end
-- Function to check if the mouse is hovering over the frame
local function Hovering(Frame)
local MousePos = _L.Services.UserInputService:GetMouseLocation() - _L.Services.GuiService:GetGuiInset()
local Guis = plr.PlayerGui:GetGuiObjectsAtPosition(MousePos.X, MousePos.Y)
for _, Gui in pairs(Guis) do
if Gui == Frame then
return true
end
end
end
function ItemFrame:setupHoverEvent()
-- Connect the InputChanged to continuously check if the mouse is over the frame
_L.Services.UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
if Hovering(self.frame) then
print("MouseEnter")
self:setupHover()
hovering = true
popUp.Visible = true
else
print("MouseLeave")
hovering = false
popUp.Visible = false
end
end
end)
end
It works however it returns a lot of false which makes it not work, however it does return true while hovering it
So its basically doing MouseEnter 1x and then MouseLeave 10x simultaneously
_L.Services.UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
local MousePos = _L.Services.UserInputService:GetMouseLocation() - _L.Services.GuiService:GetGuiInset()
local isHovering = table.find(plr.PlayerGui:GetGuiObjectsAtPosition(MousePos.X, MousePos.Y), self.frame)
if isHovering then
self:setupHover()
popUp.Visible = true
else
popUp.Visible = false
end
end
end)
Yes but even when it returns a non-nil value, after that it returns nil for some reason which makes it invisible