I am making a script that assigns a keybind to an ability depending on what you put in a certain textbox. The way it works is it has a StringValue inside of a button along with a textbox, and when something is put into the textbox, it saves to the StringValue I can't seem to figure out how to incorporate it with UserInputService though.
When you enter text, KeyBind becomes that text. (Would also appreciate it if someone knows how to cut off all the letters so only the first inputted word remains)
script.Parent.FocusLost:Connect(function()
--Key is the StringValue, script.Parent is the textbox
script.Parent.Parent.Key.Value = script.Parent.Text
end)
Script That Receives KeyBind
local Player = script.Parent.Parent
local mouse = Player:GetMouse()
local debounce = false
local UIS = game:GetService("UserInputService")
local keybind = string.lower(Player.PlayerGui.Skills.Frame.Jump.Key.Value) or string.upper(Player.PlayerGui.Skills.Frame.Jump.Key.Value)
UIS.InputBegan:Connect(function(key) --I think ??? below is the potential problem
if key.KeyCode == Enum.KeyCode.????? and debounce == false then
debounce = true
local Key = "Jump"
local char = Player.Character
local hum = char.Humanoid
game.ReplicatedStorage.Moves:FireServer(mouse.hit,Key)
wait(6)
debounce = false
end
end)

3 comments
Try Enum.KeyCode[keybind]
Also, I think the keybind letter should always be uppercase. Pretty sure that's the way most are stored in the enum, at least.
they are