I'm making a shop script where if you click on a mannequin it would return a card UI made from a billboard GUI that would show information on the clothing. Instead of making an X button to close the card, I want anywhere outside of the card to be able to close it. Because it is a BillboardGUI i cannot place a big invisible text button across the screen to cause this, unless its possible to put a billboardGUI over a screenGUI. What should I do?
One way to do it could be to get the mouse and call the Button1Down event and once the player clicks somewhere that isn't a GUI then it will fire, then you can call the code you want.
I'm not going to write the full code for you, but here is a general example of what I mean.
01 | repeat wait() until game.Players.LocalPlayer |
02 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
04 |
05 | local frame = script.Parent.Parent.Frame -- your frame goes here |
06 |
07 | mouse.Button 1 Down:Connect( function () |
08 | if frame.Visible = = true then |
09 | frame.Visible = false |
10 | end |
11 | end ) |