You can make a modulescript and use a table to create new tool tables which you can read the fields from, example code:
local Tool = {}
local defaultValues = {["MinDamage"] = 0; ["MaxDamage"] = 0; ["Name"] = ""; ["CustomEffect"] = false, ["CustomEffectFunction"] = function() end}
Tool.new = function(_MinDamage, _MaxDamage, _Name, _Description, _CustomEffect, _CustomEffectFunction)
local newTool = {}
newTool.MinDamage = _MinDamage or defaultValues.MinDamage
newTool.MaxDamage = _MaxDamage or defaultValues.MaxDamage
newTool.Name = _Name or defaultValues.Name
newTool.Description = _Description or defaultValues.Description
newTool.CustomEffect = _CustomEffect or defaultValues.CustomEffect
newTool.CustomEffectFunction = _CustomEffectFunction or defaultValues.CustomEffectFunction
return newTool
end
An example using it:
local ToolModule = require(whatever.Tool)
local Tool = ToolModule.new(10, 15, "Baseball Bat", false, nil)
print("Tool name: ", Tool.Name, "\n", "Tool damage: ", Tool.MaxDamage)
If you want you can go further with metatables like encapsulation and other stuff but it's better for you to start with basics and not burn yourself out, try to learn from the resources and not just copy and paste them.
1 comment
Metatables.