Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making a keybind for gui leaderboard but i need help?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.