Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make anywhere outside of the GUI the exit button?

Asked by 5 years ago

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?

1 answer

Log in to vote
1
Answered by 5 years ago

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.

repeat wait() until game.Players.LocalPlayer
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local frame = script.Parent.Parent.Frame -- your frame goes here

mouse.Button1Down:Connect(function()
    if frame.Visible == true then
        frame.Visible = false
    end
end)
0
thanks, this helps a lot BronzedMocha 60 — 5y
0
add in: "if frame.Visible == true then frame.Visible = false else frame.Visible == true end" and then it can work for an on and off switch. SuperSmartYoshi 17 — 5y
Ad

Answer this question