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

Making a keybind for gui leaderboard but i need help?

Asked by 4 years ago

im trying to make a keybind for a gui leaderboard but i get this error message:

PlayerGui.ScreenGui.Frame.LocalScript:10: attempt to index nil with 'keyCode'

Here is the script please help

function PopupGui() if script.Parent.Visible==true then script.Parent.Visible=false else script.Parent.Visible=true end end

game:GetService("UserInputService").InputBegan:Connect(function(key) if Key.KeyCode==Enum.KeyCode.Tab then popupGui() end end)

1 answer

Log in to vote
0
Answered by 4 years ago

This worked for me.

local gui = script.Parent
local uis = game:GetService("UserInputService")

function popupGui()
    if gui.Visible == true then
        gui.Visible = false
    else
        gui.Visible = true
    end
end

uis.InputBegan:Connect(function(input,typing)
    if typing then return end
    if input.KeyCode == Enum.KeyCode.Tab then
        popupGui()
    end
end)
Ad

Answer this question