Hello, I am fairly new to scripting. I've recently figured out how to toggle a GUI's visibility with a hotkey but now I would like to allow the player to customize that hotkey. What I am trying to do is have the hotkey changed to whatever the user sets in a textbox on the GUI. Here is what I have:

local frame = script.Parent.Parent.Frame 
local hotkey = tostring(script.Parent.Parent.Frame.ScrollingFrame.TextBox5.Text)

local UIS = game:GetService("UserInputService")
local open = false



UIS.InputBegan:Connect(function(key, gp)
	if key.KeyCode == hotkey then
		if UIS:GetFocusedTextBox() == nil then
			if open == false then
				open = true 
				frame.Visible = open
			elseif open == true then
				open = false
				frame.Visible = open
			end
		end
	end
end)

If anyone can point me in the right direction, it would be greatly appreciated. Thanks!

2 comments

0

I would use mouse input, and if it is the right input then show the gui. To change it, make a textbox where you put what you want to change it to and a button to set it. When you set it make it change the variable that is needed to show the gui.

0

It involved getting the players mouse and doing mouse.KeyDown