Module Scripts for userinputservice

Since I have so many tools that will have certain abilities, I wanna create a module script that controls it the keys for it. So for example, if the controls for each move is R,T,F,G then how would I make it so that it can control every keybinds for the tools so that I dont need to go into each tool and write code for it? Thanks

This is a pretty simple problem. If you have a collection of tools/abilities (little confused based on the wording of your post) then you can simply create a table | Roblox Creator Documentation that holds each tool/ability in it.

You can structure the code in two ways:

  1. Modular
  2. Hard-Coded

What I mean by this is that you can set up your code to loop through each tool and create a table specifically for that tool/ability. Or you can manually write code that holds all the values you want to store for each ability in the table.

I basiclly want to write one module script that controls all the tools keybinds.sorry for the confused wording lol

This is easy then. All you need is a single table that stores the tools keybinds. Once you have that you can then edit each tool keybind specifically. However, you will want to preset the keybind value’s for each ability. For example:

local KeybindController = {}

local toolAbilityTable = {
    ability1 = "E",
    ability2 = "X",
    ability4 = "."
}

local function checkKeybinds(value)
    for key, value in pairs(toolAbilityTable) do
        if toolAbilityTable[key] == value then
            return false
        end
    end
    return true
end

function module:SetKeybind(keybind, value)
    if checkKeybinds(value) then
        toolAbilityTable[keybind] = value
    end
end

return module

This can be achieved much more easily using ContextActionService.

local keybinds = {

["Dash"] = {Enum.Keycode.LeftShift,Enum.Keycode.RightShift},
["Power-Up"] = {Enum.Keycode.Q,Enum.Keycode.F},

}

Now all you have to do is go through this table, and you both can find the action name and all keycodes that should go along with this action.

UIS can capture a lot more input variety but CAS I feel is a more adaptive service that suits your needs much better.

What would I need to do in the local scripts?

I don’t know. I don’t know how your code looks or is structured.