Hello, but I need feedback and suggestions to my Tool Handler. The Tool Handler detects when you equip something and calls the module, so I don’t have to repeat Local Scripts, Scripts and Remote Events.
Here is the code:
local Player = game:GetService("Players").LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ToolsFolder = ReplicatedStorage:WaitForChild("Tools")
local function CheckTool(Object : Instance)
if Object:IsA("Tool") then
return true
end
end
local function ReturnModule(ObjectName : string)
local ToolModule = ToolsFolder:FindFirstChild(ObjectName)
if ToolModule then
ToolModule = require(ToolsFolder:FindFirstChild(ObjectName))
return ToolModule
end
end
Player.CharacterAdded:Connect(function(Character : Model)
Character.ChildAdded:Connect(function(Child : Instance)
local Tool : Tool = Child
if not CheckTool(Tool) then return end
local Module : ModuleScript = ReturnModule(Tool.Name)
Tool.Activated:Connect(function()
-- Tool Logic
end)
Tool.Equipped:Connect(function()
-- Tool Logic
end)
Tool.Unequipped:Connect(function()
-- Tool Logic
end)
end)
end)