What do you want to achieve? Keep it simple and clear!
So i’m working on keyAssign System and i need to change my OpenKey(Which include Enum.KeyCode…) with a string value like Enum.KeyCode.KeyCode
What is the issue? Include screenshots / videos if possible!
Idk if it’s possible bcz i can’ just change this
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes i did
Open script:
local function CtrlImput(input)
OpenKey = Enum.KeyCode.KeyCode -- Here i need somehow convert string to KeyCode
if input.KeyCode == OpenKey then
if CtrlDebounce == false then
gui.Visible = true
CtrlDebounce = true
else
gui.Visible = false
CtrlDebounce = false
end
end
end
UserInputService.InputBegan:Connect(CtrlImput)
And here is KeyAssign Function:
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
end)
end)
end
I have an TextButton when i click it or someone else, it waiting for Player click any button on Keyboard when he makes that OpenKey of gui becomes button which clicked Player. Example: OpenKey = B
Player Clicking text button and click button on keyboard…
Open Key = Q
Enum.KeyCode has predefined Names & Values.
Definition: Enum is a special type in the programming language where that type contains already predefined constants!
local function GetKeyOnTextChanged()
local KeyPressed
UserInputService.InputBegan:Connect(function(input)
KeyPressed = input.KeyCode
end)
return KeyPressed
end
I don’t quite understand the example, but you can achieve the check of a keyboard by checking Enum.UserInputType.Keyboard and that will detect if a player interacted with any of the buttons.
Yeah, like where you see me put in KeyPressed = input.KeyCode, it would be KeyPressed = input.KeyCode.Name. Also just gonna say, I didn’t even know it existed till now