Best way to handle ammo on guns?

I am no stranger to making gun systems, I’ve made about 2 in my whole scripting journey but this time I’m trying my hand at a proper framework, and I’m trying to make it as clean, optimized and modular as possible.

I have an obstacle in front of me though, and it’s ammo, more specifically, saving ammo for each individual gun.

I have no clue which method should I use and which one of them has the best perfomance, because obviously ammo will be depleted very fast and that may drop a few frames. (unless I am just very paranoid and wrong about things like that)

so far, these are the possible options i can think of:

  1. Use Attributes: Create attributes called Magazine and Reserve, both of which are number values, use :SetAttribute() to deplete / add

  2. Use Value Instances: Automatically create a folder with all the needed values
    image

anyone whos a lot more experienced than me, please help me decide!

From my personal experience in creating gun systems, it really doesn’t matter if you use actual value instances or attributes. Value changing is nowhere near resource heavy, even with high rates of fire of guns.

I would personally use attributes, since they’re the preferred way to handle this kind of stuff the moment they were introduced, but if you really have to use instance values for some reason you can.

1 Like