Keybind Sequence Handler
Hello! I have made a module to create sequences and bind events on them.
How to Use
-
Require the module by id or get it from the catalog. If you got it from catalog then place it inside StarterPlayerScripts.
-
Create a local script and put the module inside of the local script.
-
Open the local script and require the module.
local Keybind = require(script.KeybindSequencesModule)
Now we can use our module to create sequences.
Functions
Keybind.CreateSequence(sequenceName,sequence,CanBeReplayed)
Takes 3 parameters.Sequence name, actual sequence and if the sequence can be replayed or not.
- Sequence name must be a string and will be the name of our sequence.
- Sequence is a table that has the actual sequence in the order.
- CanBeReplayed can be a number or bool, if it is a number it will decrease every time the sequence is used and will be deleted when it reaches 0. If it is true then this sequence can be used infinitely.
Returns the sequence object.
Sequence:DeleteSequence()
Takes no parameters. Will delete the sequence when it is used on a sequence object.
Events
Keybind.SequenceFinished
Fires when a sequence is completed and returns the name of the sequence that is completed.
local function SequenceFinished(SequenceName)
print(SequenceName)
end
Keybind.SequenceFinished:Connect(SequenceFinished)
Example Usage
local Keybind = require(script.KeybindSequencesModule)
local Test = Keybind.CreateSequence("Test",{"E","Q","E","Q"},true)
local xd = Keybind.CreateSequence("xd",{"W","A","S","D"},true)
local function SequenceFinished(SequenceName)
print(SequenceName)
end
Keybind.SequenceFinished:Connect(SequenceFinished)
Place File
KeybindSequences.rbxl (29.6 KB)
My Portfolio: Zepheria’s Portfolio
Module: Keybind Sequence Handler
If you have any problems or suggestions feel free to contact me by replying or in direct messages.
Have a great day!