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

Local screengui act?ivated when pressing a button

Asked by 7 years ago

I'm trying to make a local screengui for when someone presses a button.

Can someone help me?

It's basically a screengui that appears to yourself and other specific members when you click a button.

local status = (Replace this with the GUI creator)

1 answer

Log in to vote
0
Answered by
npott13 23
7 years ago

Inside the textbutton for your gui put a LocalScript

--- First let's create a variable to find our gui
local mygui = script.Parent.Parent.Frame-- Depending on your setup, for this example i only have 4 things that is this script, This script parent which is the textbutton, The textbutton parent which is the ScreenGui, and the child of ScreenGui which is the Frame.

local check = false --- We created this bool variable so later we could use it to identify if the gui is opened or close, So now we assigned it to false assuming that our gui will be closed for the entire game unless someone opened it.

local button = script.Parent-- Now let's create a variable called button and assign it to script.Parent (TextButton)  we could use this later for the clicking event.

button.MouseButton1Click:connect(function() --- We let this function know that whenever the button is click we want something to happen which is the lines below.

 if check == false then -- We use the bool variable to know if the gui is show, but since we defined it as false it will show the gui whenwe click the button for the first time.
 mygui.Visible = true --- We want it to show our frame
 check = true --- We updated our bool to let the script know that our gui is currently opened.
 elseif check == true then --- Now when we click the textbutton and the check is true (gui opened) then the script will close the gui. 
    mygui.Visible = false -- Closed
    check = false --- We updated our bool so when we click again it'll open.

end

end)
Ad

Answer this question