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

Open GUI on Key?

Asked by
sgsharp 265 Moderation Voter
10 years ago

I'm looking to create a shortcut to opening my game's Menu GUI. The shortcut will be the press of the key, "X" or something like that...

I would greatly appreciate it if someone would help me out with this...

Please provide specific details/sources. (It helps me learn faster)

Thanks for the help!

1 answer

Log in to vote
2
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

Use the KeyDown event.

--LocalScript
repeat wait() until game.Players.LocalPlayer
local p = game.Players.LocalPlayer
local m = p:GetMouse()
local folder = p.PlayerGui:WaitForChild("GUINAME")
local guitoopen = folder["Directoryhere"]

m.KeyDown:connect(function(key)
    if key:lower() == "x" then 
        if guitoopen.Visible then 
            guitoopen.Visible = false
        else
            guitoopen.Visible = true
        end
    end
end)
1
Thanks! sgsharp 265 — 10y
Ad

Answer this question