Currently making a customizable keybinds tab, I’m trying to only collect a player’s input only once with UserInputService.
Problem is, once I get that first value, I can’t find a way to break out of that InputBegan event.
My current system/attempt:
I have a button, once clicked, it has the InputBegan event within it. Once you press it, it starts printing input data to the console.

My outcome:

My desired outcome:
Once I input anything as a player, the event disconnects and stops printing.
My relevant code:
ToggleCameraModeButton.MouseButton1Click:Connect(function()
KeybindsTitle.Text = 'Input a key to be binded. \n Press backspace to cancel.'
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode ~= Enum.KeyCode.Backspace and input.UserInputType == Enum.UserInputType.Keyboard then
print(input.KeyCode)
elseif input.KeyCode == Enum.KeyCode.Backspace then
KeybindsTitle.Text = 'Keybinds'
end
end)
end)
If I didn’t explain that well enough, let me know. Not sure if I explained this accurately.