Hey there! I want to make a skill system, where there are set keys (E R T Z X C), and you can set keybinds to them. For example, when you press a button / key, a UI will open. In said UI, there will be a list of your skills. You would click on a skill then click on the key.
This would be considered similar to Jujutsu Chronicles’ system.
For reference:
Icon that show the skills and the keys they are assigned
You would want to use something like UIS or CAS (UserInputService, ContextActionService) to bind each button, and once the button is pressed, fetch the corresponding ability that the player has equipped. What I would do is assign each ability to a number (Z = 1, X = 2, C = 3, ETC), and once the code detects a key is pressed, first check if its one of the skill keys. If it is a skill key, check which skill is attached to said key (I would use a table held inside of a string value to store this data), and if they have it equipped then have a module with all the abilities client code, and run the data there. ALWAYS MAKE SURE TO DOUBLE CHECK IF THEY CAN USE THE ABILITY ON THE SERVER
use UIS to check if the inputs that the user makes are the keys that you are looking for in the UI
you can also use UIS to know what key the user wants to bind that skill to
local uis = game:GetService("UserInputService")
local skillKey1
uis.InputBegan:Connect(function(inpObj, processed)
if isSelectingKey then
skillKey1 = inpObj.KeyCode
elseif inpObj.KeyCode == skillKey1 then
-- do skill
end
end)
Thank you, you have given me an idea. So I would have a table set in the character like this:
{
["E"] = "FireJab",
["R"] = "FlameRotation",
["T"] = "Jet Propulsion",
["Z"] = nil,
["X"] = nil,
["C"] = "Fire Wall",
}
And it would be stored in a datastore. Each time the player updates it, it will be saved to the datastore again, as well as when the player leaves the game.
A Local script that will fire a remote event / remote function for each key. For example
if input.KeyCode == Enum.KeyCode.E then
ability1:FireServer()-- or InvokeServer()
end
``
A server script that will listen for the remote, and it will send back cooldown and fx.
```lua
function remote(ability1 : RemoteEvent)
ability1.OnServerEvent:Connect(function(player)
local moveset = player:FindFirstChild("Moveset")
local abilityName = moveset["E"]
end)
end
Well the way i work is with instances, but for your case youd want to do something as follows
local abilities = { -- This will be relative to what the player has equipped
Enum.KeyCode.E.Value = "FireJab",
Enum.KeyCode.R.Value = "FlameRotation" --etc
}
local abilitiesModule = require(game:GetService("ReplicatedStorage").Abilities --abiities module where all the client code is stored for the abilities
game:GetService("UserInputSerivce").InputBegan:Connect(function(input, gpe)
if gpe then return end --basic uis stuff
if abilities[input.KeyCode.Value] then --if the key pressed matches an entry inside of the table
abilitiesModule[abilities[input.KeyCode.Value]]() --Finds the function inside of the abilities module with the exact name as the one inside of the table that is assigned to the key
end
end)
Very simplistic design, all you do is put the name of the functions inside of the table, assign it to a keybind, and once an input is detected, check if the input is listed in the table, if it is then search a module for the corresponding function and run it.
I did not see this! Okay so making sure that I understand, I would turn E,R,T,Z,X,C into 1,2,3,4,5,6. When the client fires the remote for said key, loop through a table to find out which key is there, and run it. So I assume that for swapping / changing skills for keys, I would have to make a UI with buttons for each key, and UIGridLayout for all the skills, and when a skill is pressed then the key is pressed, it will fire to the server and the server will do the switching and the logic, correct?
Okay so I think I might have confused you. So the table of strings like “E” and “R” etc, are for the server and client. It is showing their current skillset/ loadout. I don’t send any information to the server right now
But in all, I think we have gotten off topic from my perspective. I am not saying that these have not been helpful, I have not scripted the skills yet. I am trying to make some “dummy skills” to test switching and casting. My original problem was that I had no clue on how to switch an item.
Let’s say the user had Earth wall set to E, but they wanted to switch it with Earthquake. How would I do that?