Is there a way to know correctly whatever the mouse is hovering in GUI?
I tryed to do this script
local Plr = game.Players.LocalPlayer
local GuiE = GetAllChildren(Player.PlayerGui) --Custom function that give an array of all childrens (more that :GetChildren(), this function is working very well!
local GUIET = nil
local T={}
local i=0
for i=1,#GuiE do --Mouse detector!
table.insert(T,i,false)
pcall(function() --It can be a Folder or something that isn't a Gui object
GuiE[i].MouseEnter:Connect(function()
T[i]=true
end)
GuiE[i].MouseLeave:Connect(function()
T[i]=false
end)
end)
end
while wait() do --It changes GUIET to return what the mouse is hovering
for i=1,#T do
GUIET=nil
if T[i] then
GUIET=GuiE[i]
end
end
end
This work but the Script is too heavy and it uses a lot of performances (crucial for slow devices) and it don’t work sometimes (when two objects are in the same spot) AND it’s even unstable (from why the usage of a pcall)
I’m looking for a way to get correctly the Gui Object but in less lines of code (like the Target propertie of Mouse)