How to make a KEY to open a GUI Roblox Studio tut

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024
  • In todays video I show you how to make a KEY to open a Gui in Roblox Studio. How it works is when a player clicks a key on their keyboard a gui then opens, but then when they click x again it will then close I hope this helps!!
    local UserInputService = game:GetService("UserInputService")
    local gui = script.Parent:WaitForChild("Frame") -- Change 'Frame' to the name of your GUI element if different
    local guiVisible = false
    -- Function to toggle GUI visibility
    local function toggleGUI()
    guiVisible = not guiVisible
    gui.Visible = guiVisible
    end
    -- Function to handle key press
    local function onKeyPress(input, gameProcessed)
    if input.KeyCode == Enum.KeyCode.X then
    toggleGUI()
    end
    end
    -- Connect the input event to the function
    UserInputService.InputBegan:Connect(onKeyPress)
    roblox pfp: www.roblox.com...
    roblox group: www.roblox.com...

Комментарии • 5