How do I make a key switch system with a textbox?

Well what I want to do is a scripting KeyBind change system like this

local Mapa = script.Parent.Mapa
local Open = false

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:connect(function(keyCode)
	if keyCode.keyCode == Enum.KeyCode.M then
		if Open then
			script.Parent.Frame.Visible = false
		else
			Open = true
			script.Parent.Frame.Visible = true
		end
	end
end)

I want to do that when writing a letter in a text box, the script captures it and saves it for when you want to execute it you have to press the letter on your keyboard executing the script, what do I do?

You could make it capture the new text via an event and use that to set a variable and make the Inputbegan event reference that variable for the name of the KeyCode

local Mapa = script.Parent.Mapa
local Open = false
local keyText = ""

local TextBox = --Your textbox location

TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	keyText = TextBox.Text
end)

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:connect(function(keyCode)
	if keyCode.KeyCode.Name == keyText then
		if Open then
			script.Parent.Frame.Visible = false
		else
			Open = true
			script.Parent.Frame.Visible = true
		end
	end
end)
2 Likes