So Im having trouble with GUI hotkeys. I know how to script the actual hotkey, but I dont want it to be a single letter such as H, I want it to be Tab but I don't know how to do that, I also need it when you hold the tab the gui is open and when you release it goes away, my starting code is here
p = game.Players.LocalPlayer mouse = p:GetMouse()
mouse.KeyDown:connect(function(key) if key == "H" then if script.Parent.Visible == true then script.Parent.Visible = false else script.Parent.Visible = true end end end)
You have to use UserInputService. Here's an example that fires an event
local uis = game:GetService('UserInputService') if uis.KeyboardEnabled then --Player is using a keyboard uis.InputBegan:Connect(function(input) --Something was pressed or clicked if input.KeyCode = Enum.KeyCode.A then --If they pressed a on the keyboard game.ReplicatedStorage.Event:FireServer() --Fire event end end) elseif uis.GamepadEnabled then --player is using a controller uis.InputBegan:Connect(function(input) if input.KeyCode = Enum.KeyCode.ButtonA then --If they pressed a on the controller game.ReplicatedStorage.Event:FireServer() end end) end