Hey, How can i do a keyDown function do the same thing only make it reappear and dissapear if you press the same button?
How can i make a gui pop up and go away with one single keydown?
2 answers
You would use the KeyDown event and check if the GUI is visible. If the GUI is not visible then make it visible vice versa.
Example
mouse.KeyDown:connect(function(k)
if k:lower()=="t" then
gui.Visible=not gui.Visible
end
end)
1 comment
I'm not sure if line 3 would work..
For this then you will need a KeyDown Event. And you can, like l0cky said, change the visibility of the gui to the opposite of it was when you pressed the key, or you can delete it and make it reappear. I'm going to explain the latter since you already have an example of the Visibility method.
--LocalScript
mouse = game.Players.LocalPlayer:GetMouse() --Get the players mouse
val = 0 --I'll explain later
keyy = "g" --The key to press
gui = PathToGui --Specify the gui to appear / reappear
mouse.KeyDown:connect(function(key) --Keydown event
if key:lower() == keyy then --Check the key they pressed
val = val + 1
if val == 1 then
g = gui:Clone()
g.Parent = game.Players.LocalPlayer.PlayerGui
g.Name = "ClneGui"
elseif val == 2 then
game.Players.LocalPlayer.PlayerGui:FindFirstChild("ClneGui"):Destroy()
val = 0
end
end
end)
So what I did here is I made a value, set it to zero, so when they press 'g' the first time, it moves the value to 1, and malkes the gui appear. If it's at 2 then it sets it to 0 and destroys the gui. So it's like a neverending loop.
Hope you're satisfied with this explanation if not tell me I'd be happy to explain further(:
-Goulstem
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I'd prefer if you would try this yourself first and come back with results if you couldn't figure it out..