I can Press Button when GUI is over

Hey, I’m having an issue with some Button that are still clickable when a GUI is on top.
Is there a Way to Fix that ?

https://i.gyazo.com/ac68008af2bcd83c811ce22769731b82.mp4

2 Likes

You can add an invisible TextButton that fills up the black frame so it blocks out the actual button behind it.

Is there a reason that there is a text button behind the frame?

Perhaps disable the button, change the index value of both instances, or hide the button when the other frame is open.

No that change nothing… Soo there is no Simple Solution to that ?? its a real issue !

You have to make the Zindex on the button less than the zindex on the inventory or whatever the black frame iis maybe?

Set the top GUI’s Active property to true.

Even with that , I can still interact with the button under the GUI

1 Like

You’re sure it’s the black half-transparent frame that you’re setting to Active, right? Probably should have clarified in my prior post.

1 Like

yes ! its exactly that one. Its strange that I cant find any information about that on google

1 Like

Really weird.

This won’t disable the button, but maybe you could create a value which checks if that upper UI is open, and if it is, don’t do any actions for the lower UI, and just do actions for the upper one.

Did you try changing the ZIndex to a higher value? I’m a little confused as to what you’re trying to do.

yeah I tried it… soo Roblox have a problem with GUI interaction in that case… If I have some button under a UI and I’m are able to click on it … its not a proper Behavior !

I think I see your issue. You don’t want the button to be pressable when a UI is there, correct? Unfortunately, you can’t do much about it. You’ll have to create a clone of the button, instead, it’s a frame of the button.

If you live, you can set the button’s active property to false while the GUI is open, then reenable it when it’s closed.

1 Like

Hello!

There is a function of all BasePlayerGui called GetGuiObjectsAtPosition You can find it here.

You can get the BasePlayerGui from the object PlayerGui under the LocalPlayer instance. Here is an example:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local playergui = player:WaitForChild("PlayerGui")

playergui.PathToButton.MouseButton1Click:Connect(function()
    local guisonmouse = playergui:GetGuiObjectsAtPosition(mouse.X,mouse.Y)
    
    if #guisonmouse > 1 then
        -- You can always change the number if there is more objects!
        return
    end
    
    print("There was only found one gui object at mouse position!")
end)
2 Likes

You can just set Visible = False of the frame behind that, no scripting and stuff like that. That worked for me.