Brief Description
- Tired of having multiple scripts per tool? I created a module that lets you handle many different tools at once.
How does it work?
- The module allows you to assign different groups to tools using TAGS. You can then use those tags to preform functions/events on those specific groups. The module also allows you to setup key binds for tools in groups and has a built-in cooldown/debounce system.
- Add a TAG to the tool instance.
Documentation
Setup:
local replicated = game:GetService("ReplicatedStorage")
local handler = require(replicated["Tool Handler"]) -- Used To Update Cooldown and Create A New Group
local client = handler:NewClient() -- Used For Events
Add New Group:
local swords = handler:RegisterGroup("Swords") --Returns string
Update cooldown/debounce:
handler:UpdateCooldown(swords,0.5) -- group name, cooldown
Equipped and UnEquipped:
client.Equipped("Swords"):Connect(function(tool) --Returns tool
print(tool.Name.. " Was Equipped")
end)
client.UnEquipped("Swords"):Connect(function(tool) --Returns tool
print(tool.Name.. " Was UnEquipped")
end)
Auto-Fire / Hold down activated:
--[[
This function is used for automatic clicking (example; guns),
The event will fire if the player is clicking down on the screen whilst using the
groups set cooldown/debounce.
--]]
client.RepeatActivated("Pistols"):Connect(function(tool)
print(tool.Name.. " Was Fired Using Repeat-Activated")
end)
Activated and Deactivated:
-- The Activated also uses the groups set cooldown/debounce.
client.Activated("Grenade"):Connect(function(tool)
print(tool.. " Was Clicked")
end)
client.DeActivated("Grenade"):Connect(function(tool)
print(tool.. " Was DeActivated")
end)
Keybinds:
--[[
Allows up to two keybinds (mainly used for PC and Console)
--]]
client.KeybindClick("Combat",Enum.KeyCode.F,Enum.KeyCode.ButtonX):Connect(function(tool)
print(tool.. " Keybind Was Pressed")
end)
client.KeybindRelease("Combat",Enum.KeyCode.F):Connect(function(tool)
print(tool.. " Keybind Is Released")
end)
This is my first public resource on here, feedback is appreciated