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

Someone help with Keypress Script??

Asked by 10 years ago

I have a GUI and I want to press a key, for example 'X' and the gui will open Press X again and it will close

2
Include a script. Redbullusa 1580 — 10y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

This isn't a request site, but since this script is fairly easy... You need to use the KeyDown event as well as debounce.

Local Script

mouse = game.Players.LocalPlayer:GetMouse()
open = false
mouse.KeyDown:connect(function(key)
    if key:lower() == "x" then
        if open == false then
            script.Parent.Frame.Visible = true
            open = true
        else
            script.Parent.Frame.Visible = false
            open = false
        end
    end
end)
Ad

Answer this question