Hello DevForum! I tried making a script where you can change a keybind. Let me explain:
There is a value in ReplicatedStorage just named “Value”, and that holds the current keybind, which is G.
Here’s the script that detects that input:
local key = game.ReplicatedStorage.Value.Value
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode[key] then
print("Worked!")
end
end)
Now it works perfectly, but when I try changing the KeyBind, here is what happens:
Here’s the script:
local uis = game:GetService("UserInputService")
local key = game.ReplicatedStorage.Value
script.Parent.MouseButton1Down:Connect(function()
script.Parent.Text = "Waiting for input.."
uis.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
print(tostring(input.KeyCode).. " is the new KeyBind!")
key.Value = tostring(input.KeyCode)
end)
end)
I have that script inside a text button for where when you click it, the script is fired.
Now my problem is that it is not changing the string value’s value in replicated storage, and I even made a print function to print what the input is, and its printing out “Enum.KeyCode.F” for example, and I need it to only happen once every time the gui is clicked. If there are more details needed, I can explain.