I’m trying to make a gun system, this is how it’s looking right now:
Main module script:
local framework = setmetatable({}, {})
framework.__index = framework
function framework.new(tool, config)
local self = setmetatable({}, framework)
self.Instance = tool
self.Config = require(config)
tool.Equipped:Connect(function()
print(self.Config.name .. " equipped")
end)
return self
end
return framework
local script in each gun:
local framework = require(game:GetService('ReplicatedStorage').GunFramework)
local gun = framework.new(script.Parent, game:GetService('ReplicatedStorage')["Guns Data"]["G17"])
Is there a better way to do this? The scripts in each gun/tool are all basically the exact same which leaves me just copy and pasting the same code and making minimal changes, aside from the name of the gun. I’m looking for a different way I can be doing this