Now I am nowhere near a new GUI developer or scripter, but either this wasn’t a thing before or it has literally taken me a full year and a half of near-constant development to notice this. I am currently working on a project for someone and the GUI I am working on is a shop GUI that has tabs that you would click to change what page of the GUI you are viewing. This isn’t a new concept to me and I doubt it’s a new concept for you, but the part that I am finding problems with is actually what I am doing with them. I have them expanded a fair bit down into the borders, if I had to guess it would be maybe 1/8th down my GUI, which isn’t a lot for its size. I am doing this because I want when the player hovers their mouse over the portion of the tab that sticks out, the tab is tweened out like someone is pulling a file out of a filing cabinet. This system is working fine, my problem lies in the [GuiObject].MouseEnter/MouseLeave triggering when the player has their mouse on the GUI that covers the bit that extends downwards so it can pull out. I am also experiencing problems where you can click the buttons through the GUI. If anyone knows a way to fix this, I’d like to know, because I’ve already checked my ZIndex, I’ve checked my scripts, and I’d prefer not to have to rewrite my code to include an exclusion for if the mouse is in the overlaying GUI if there is another method to fixing this.
I am also mentioning this because I’m certain there are newer developers who can’t type on this forum yet probably experiencing this same problem. If anyone knows the solution or has an idea, tell me and I will attempt your idea/solution and tell you if it worked!
I’m working on something very similar right now and ran into consequently similar problems.
Unfortunately, Active won’t help you here: the events will still trigger. Your solution is, unfortunately, to either write a handler (which you have voiced disdain for), or restructure your design so that the elements do not overlap.
In my system, I shrunk down my buttons and replaced the empty space with frames of the same color, but this may not work for you depending on how players are to interact with your tabs.
Since as MysteriousVagabond has pointed out appears to be true, I have made a simple handler for if the mouse is in the borders of the GUI that I don’t want to trigger the tabs when it is inside. Not very hard to do, but more of a pain because it requires adding a fair amount of lines to your scripts to figure out when it is inside the borders.
For anyone who wants the solution, I did this:
local isOpen = false
local mouseInFrame = false
script.Parent.MouseLocater.MouseMoved:Connect(function()
if isOpen == true then
mouseInFrame = true
else
mouseInFrame = false
end
end)
script.Parent.MouseLocater.MouseEnter:Connect(function()
if isOpen == true then
mouseInFrame = true
else
mouseInFrame = false
end
end)
script.Parent.MouseLocater.MouseLeave:Connect(function()
mouseInFrame = false
end)
And to stop the tabs from detecting if the mouse is inside them through another GUI:
[GuiObject].MouseEnter:Connect(function()
if isOpen == true and mouseInFrame == false then
--Code goes here
end
end)
[GuiObject].MouseLeave:Connect(function()
if isOpen == true then
--Code goes here
end
end)
For those who attempted to help, once again, thank you, and for anyone in the future who looks at this post, I hope you find some valuable information from here!