Action Module
In your wally.toml file, add this to your dependencies:
You have two solutions to import this module, depending if you wish to import the Controller or the Service on your own, or if you let the module give you the right code.
A file called ActionModule.config.lua is to be created in the folder ReplicatedStorage/Shared/Configs.
Explanation:
Fight: The name used to refer to your action. This name is unique, it cannot be referenced twice.
Key: The Key to which your callback function will be bound.
Cooldown: The minimum time required between two uses of the action.
DefaultCallback: The default callback function for the action. This can be updated later using
Action:BindCallback(callback).
Usage
Client Side Functions
This method allows you to listen to an event sent by the ActionService and run a callback function whenever an event is received.
List of events:
OnActionPerformed: Called when a player uses an action. Sends the name of the action as a parameter. Called only if the action succeeds.
Usage
Explanation
name: The name of the event you wish to listen to.
callback: The callback function that will be run whenever this event is received.
Server Side
This method is called automatically when a player uses the key bound to an action. However, it can be called manually when needed using this function.
Usage
Explanation
player: The player performing the action.
action: The name of the action that the player will perform.
This method is called automatically when the server starts, binding the actions to their keycodes from the configuration. However, it can be called manually when needed.
Usage
Explanation
name: The name of the action.
cooldown: The minimum time required between two uses of the action.
callback: The default callback function for the action.