If you understand how to do OOP, then you can make an inherited class list. Each unique tool has their own ModuleScript, containing information that you would like about the object. Every tool would absorb their ancestor’s functions, or have any functions overridden if defined in a more recent class.
Our first class, the very beginning would be a specific weapon. For example, a “Wooden Sword”.
local ancestorClass = require(MeleeClass)
local class = setmetatable({}, ancestorClass)
class.__index = class
function class.new(root, character)
local new = setmetatable(ancestorClass.new(root), class)
new.root = root
new.Model = script.Model:Clone()
new.Damage = 15
return new
end
return class
obviously change the ancestorClass variable to the ancestor type, such as a melee weapon or whatever you would need.
Now for the first ancestorClass, a generic melee weapon class.
local ancestorClass = require(BaseClass)
local class = setmetatable({}, ancestorClass)
class.__index = class
function class.new(root)
local new = setmetatable(ancestorClass.new(root), class)
new.root = root
return new
end
function class:M1()
-- Weapon attack logic, such as animations, sounds, remote events, etc.
end
return class
Now for the final and very generic Tool class. Note that all tools will eventually return to this class and so the script structure is more unique.
local class = {}
class.__index = class
function class.new(root)
local new = setmetatable({}, class)
new.root = root
new.__index = class
return new
end
function class:EquipTool(tool, parent)
-- Called when the tool needs to be cloned and parented to the player.
end
Now for explaining why and what.
function class.new(root)
end
The new constructs the class, and will be called for when a tool is created. The base tool is structured differently as it will be the most highest parent, and so it creates the original metatable.
Each child class will override or add new data and functions. The __index is used to tell the metatable that it can collect all of the functions in the class itself, so that everything is collected when invoking class.new()
If you have no idea about OOP, then I can explain further. But this is my best attempt at explaining what you are trying to achieve.