I want to allow players who play my games to edit their own controls. So in my game if “E” is open doors, I would like to allow them to change that to any other button.
I’ve searched the forums to see if anyone has asked for help on this and I can’t find any posts. Does anyone have any places I can look to see examples of how to start?
Never implemented this before, but this seems like a fairly simple task.
Create string values which is responsible for what key the control is bound to.
Allow the player to edit these values in a local script.
If the player presses the key, do something.
Enum.KeyCode includes a table, so you can refer to any key from in it by using brackets.
As everything in Enum.KeyCode is capitalized, use string.upper to refer to KeyCode values.
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local Character = player.Character
local OpenDoorKey = Character.Humanoid.OpenDoorKey.Value
UIS.InputBegan:Connect(function(input, gameProcess)
if not gameProcess then
if input.KeyCode == Enum.KeyCode[string.upper(OpenDoorKey)] then
print(tostring(input.KeyCode) .. " has been pressed")
end
end
end)
Thanks so much for this example! I’m super curious why games with custom controls are non-existent on Roblox. Especially because like you said, it doesn’t really seem too difficult.
Its just never been an issue on Roblox, so people have never had a reason to make it. They might become popular when a popular game implements the system