How would I make it so when the player clicks a UI Button they get a specific ability?

Hello. Im making a game where you choose a character with abilities, and Im having a little trouble with the abilities part. Does anyone know how I would go about making it so that when the player clicks a ui button, they get a set of abilities (like you click to punch, press E to kick etc.)? Any help would be greatly appreciated!

When the player clicks the button/presses the desired key, it will fire an event to the server and the server will handle the ability request. I suggest using either modulescripts or functions inside the ability request script and call those functions.

The functions or modulescripts will contain the code for the ability.

You need to make when the player uses the button, It uses a remote Server that can transfer some special informations depending on your ability, For a fire ability, its very easy to make!

And dont forget to use debounce since the player can probably spam.

Heres a example of what you would do to create a ability.

local uis = game:GetService('UserInputService')
local db = false
local r = -- [ your remote event

function ability(key, gameproc)
      if (not gameproc and db == true) then
             if key.KeyCode == Enum.KeyCode.E then -- [ you can change E to any button on the keyboard, if you want to use the mouse, use UserInputType instead of KeyCode.
                    db = true
                    r:FireServer(-- your informations being transfered to the server)
                    wait(-- cooldown)
                    db = false
             end
      end
end

uis.InputBegan:Connect(ability)

Server Script →

game.ReplicatedStorage.Test123.OnServerEvent:Connect(function(Player, -- you can add anything 
here)
       -- [ local hrp = Player.Character.HumanoidRootPart, You might want to need this!
       -- [ your ability script..
end)

You can put any name on your Remote Event its just a test By the Way.