Greetings, so what I’m trying to achieve here is assigning each abilities’ moves to keybinds. To give more explanation, it’s similar to any battlegrounds game. You click an ability in a GUI, it then gives you custom combat systems, moves/abilities for that character. There is an in-efficient way of doing this, which is creating multiple if statements checking the player’s ability and input. But it’s extremely inconvenient. Another one could possibly be making a modulescript containing all the abilities and their keybinds? If so, how would I go on to make the framework? This is what is mostly confusing me, maybe a table to loop through all the keybinds in the required module? It would be very appreciated if you’d give feedback. (Also, how would implement a custom combat for that ability?)
This is what I would do:
--Local Script
local UIS = game:GetService("UserInputService")
local KeybindFunctions = require(WhereverTheModuleScriptIs)
UIS.InputBegan:Connect(function(Input)
KeybindFunctions[Input.Keycode]()
end)
--Module Script
return{
[Enum.KeyCode.ExampleKeyCode] = function()
--Code
end,
}
1 Like