Hello. I’m making a gun system and I want to add “perks/traits” that players can equip. For example: “Reload speed for all your guns is increased by 20%,” but the issue with this is that I’m not sure how I would implement this into my current code? So far, I have a module in each tool that stores all the data for the tool that the server-script for the gun uses. Would I just be able to modify this data by doing something like ``RELOAD_TIME = 2.2"? I’m not sure how I would be able to implement this.
local Constants = {
FIRE_MODE = "Semi", -- Only accepts "Semi" or "Auto" as arguments
SHOT_COOLDOWN = .075,
BULLET_LENGTH = 125,
BULLETS_PER_SHOT = 1,
BULLET_DAMAGE = 12,
RELOAD_TIME = 2.5,
MAGAZINE_SIZE = 15,
RAY_SPREAD = 2,
}
return Constants
Yup! Except if you require the module from another script (depending on what type of script you are using) it may still be the default, just so ya know
Well the way my system works is I’m just requiring it through a server script that is inside the gun’s Tool object. Heres a little snippet of code
local function onShootEvent(player: Player, mousePosition: Vector3)
if ammoValue.Value <= 0 then -- If the player tries to shoot but has no ammo, then the gun will reload
onReloadEvent()
end
if not canShoot() then
return
end
ammoValue.Value -= 1
sounds.Fire:Play()
isCoolingDown = true
task.delay(Constants.SHOT_COOLDOWN, function() -- Here I use data from the module
isCoolingDown = false
end)
for amountOfBullets = 1, Constants.BULLETS_PER_SHOT do -- Here I also use data from the module
fireBullet(mousePosition)
end
end