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

How do i get my open and close gui script to work?

Asked by
alsome495 -21
7 years ago
local ScreenGui Production

function wait
if Visible = true
    then wait(5)
    then visible = false
end


0
My script is in a LocalScript and it wont work i just want it to play then the player spawn in alsome495 -21 — 7y

2 answers

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

I'd give you a walkthrough of what you did wrong, but it is just about everything.


Lets start with how you should define the gui. The localscript should be placed directly inside of your TextButton/ImageButton. This way, it is easily accessible by using script.Parent.

local ScreenGui = script.Parent

Next, you need to setup your function. The correct syntax to do so is:

function [name] (arguments)

[code]

end

function Click()
end

Now you can manipulate the Visiblity of your Gui.

function Click()
    ScreenGui.Visible = not ScreenGui.Visible
end

And finally, you need to tie your function to an event. Events in roblox are "listeners" that will fire whenever a specified action occurs. You tie functions to Events in order to make them, well, functional :)

Full product:

local ScreenGui = script.Parent

function Click()
    ScreenGui.Visible = not ScreenGui.Visible
end

--MouseButton1Click is the event that handles clicking for UI ButtonObjects
script.Parent.MouseButton1Click:Connect(Click)
Ad
Log in to vote
0
Answered by 7 years ago
  1. Add a script into Button Or ImageButton then do this
bin = script.Parent
function Click()
    script.Parent.Parent.(NameOfTheGui).Frame.Visible = true

end

bin.MouseButton1Click:connect(Click)

2.Add another script into button or imageButton And the Button's parent should be the opened GUI then Write this

bin = script.Parent
function Click()
    script.Parent.Visible = false

end

bin.MouseButton1Click:connect(Click)

Answer this question