local function ChangeKeyBind()
KeyBindButton.MouseButton1Click:Connect(function()
KeyBindButton.Text = "Waiting for Input..."
UserInputService.InputBegan:Connect(function(input)
local KeyPressed = input.KeyCode.Name
KeyCode = KeyPressed
KeyBindButton.TextScaled = "Change KeyBind... Current Keybind: "..KeyCode
end)
end)
end
Alright wait, how does this do for you? Maybe we didn’t have to make the keypressed a string, but the end part where you send a print needs to just have the name
UserInputService = game:GetService("UserInputService")
KeyBindButton = script.Parent.ScreenGui.TextButton
local KeyCode
local function ChangeKeyBind()
KeyBindButton.MouseButton1Click:Connect(function()
KeyBindButton.Text = "Waiting for Input..."
UserInputService.InputBegan:Connect(function(input)
local KeyPressed = input.KeyCode
KeyCode = KeyPressed
KeyBindButton.TextScaled = "Change KeyBind... Current Keybind: "..KeyCode.Name
end)
end)
end
local function CtrlImput(input)
if KeyCode == "RightControl" then
else
OpenKey = Enum.KeyCode..KeyCode
end
if input.KeyCode == OpenKey then
if CtrlDebounce == false then
gui.Visible = true
CtrlDebounce = true
else
gui.Visible = false
CtrlDebounce = false
end
end
end
local Keys = {
OpenGui = Enum.KeyCode.LeftControl
}
local CtrlDebounce = false
local UserInputService = game:GetService("UserInputService")
local function CtrlImput(input)
if input.KeyCode == Keys.OpenGui then
if CtrlDebounce == false then
CtrlDebounce = true
print("Is shift")
Keys.OpenGui = Enum.KeyCode.LeftShift
else
print("Is ctrl")
CtrlDebounce = false
Keys.OpenGui = Enum.KeyCode.LeftControl
end
end
end
UserInputService.InputBegan:Connect(CtrlImput)
local function CtrlImput(input)
if KeyCode == "RightControl" then -- We don't need to check if it's a string...
else
OpenKey = Enum.KeyCode..KeyCode
end
if input.KeyCode == OpenKey then
if CtrlDebounce == false then
gui.Visible = true
CtrlDebounce = true
else
gui.Visible = false
CtrlDebounce = false
end
end
end
Instead:
local function CtrlImput(input)
if KeyCode == Enum.KeyCode.RightControl then
else
OpenKey = KeyCode
end
if input.KeyCode == OpenKey then
if CtrlDebounce == false then
gui.Visible = true
CtrlDebounce = true
else
gui.Visible = false
CtrlDebounce = false
end
end
end