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

Toggle GUI Visibility on key press. (Meaningless Question mark ?) [closed]

Asked by 7 years ago

How would I make it so when a key is pressed the, GUI is visible to whoever pressed the button.

0
Do you know how to use UserInputService? PolyyDev 214 — 7y

Closed as Not Constructive by Goulstem

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
PolyyDev 214 Moderation Voter
7 years ago
Edited 6 years ago

In a localscript do:

local uis = game:GetService("UserInputService")

local gui = script.Parent --// Define the gui

local open = false

uis.InputBegan:Connect(function(key)
    if key == Enum.KeyCode.K and not open then
        gui.Enabled = true
        open = true
    elseif key == Enum.KeyCode.K and open then
        gui.Enabled = false
        open = false
    end
end)

Accept answer if it works else tell me

0
It Dosen't disable the GUI https://gyazo.com/3e9111d48056d94df699978e930caca8 <----For Reference Lord_Nermall 1 — 7y
0
I edited it, try now PolyyDev 214 — 7y
0
I've Tried it both with the GUI Pre-Enabled and Disabled. Didn't work. Lord_Nermall 1 — 7y
0
Go to the discord and seek help PolyyDev 214 — 7y
Ad