You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Well I’m wondering if it’s possible to make a custom keybind sort of thing, if the player choose F to be the key or if the Player choose R to be the key, is this possible?
What is the issue? Include screenshots / videos if possible!
I don’t know where to start, as I’ve tried to figure out how to make it or how to go about it, I’ve done alot of searching but I can’t find anything relating to it
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yeah I’ve looked for solutions on the Hub and also on the Web but I haven’t be lucky enough to find a solution
local uis = game:GetService("UserInputService");
script.Parent.MouseButton1Click:Connect(function() -- the player presses a button to change the keybind/initiate it
uis.InputBegan:Connect(function(key)
-- do whatever you want with key.KeyCode
end)
end)
Going off of what @ScriptedSuper said, you could simply contain a variable for each bind, such as
Zoom = Enum.KeyCode.Q
and allow the user the manipulate that value, probably through some UI menu. From there, using the Input Began function you can check if the key = Zoom
Zoom = Enum.KeyCode.Q
local uis = game:GetService("UserInputService");
script.Parent.MouseButton1Click:Connect(function()
uis.InputBegan:Connect(function(key)
if key.KeyCode = Zoom then
--Action
end
end)
end)
local userInput = game:GetService("UserInputService")
local textbox = script.Parent
userInput.InputBegan:Connect(function(input, processed)
if processed then return end
local success, result = pcall(function()
return Enum.KeyCode[textbox.Text]
end)
if success then
if result then
if input.KeyCode == result then
print("Hello world!")
end
end
end
end)