Using table.insert to insert a value to a table that can be referred with a number?

Hey! so, im still kinda new with tables (but a advanced scripter), and im making a admin system for my game that has a no firerate function

What i want to achieve is, if the toggle is activated it will put the firerate at 0.01, else it will put the firerate on the original firerate. And if found the easiest way to do that would put all the firerates in a table accompanied by the gun name, and the firerate is a number value, can anyone help me achieve that?

Thanks in advance!

With what you’re asking you can use tables like a dictionary…

local FireRate = {}
FireRate[“AK47”] = .75

Then you can reference that by just specifying FireRate[“AK47”], or using a variable

but then how i would go about inserting the value to the table?

Where I put

FireRate[“AK47”] = .75

This would specify the fire rate, you can always adjust it in the future by simply writing the same line as such
FireRate[“AK47”] = 1.5

If you’re going to always have the “Activated” rate at .01 then that can be specified when you activate and then when you “Deactivate” you’d call this table with the name referenced to the gun desired to get the “Original” fire rate.

If you wanted to store different activated rates you could add a secondary table inside each gun like such

local FireRate = {}
FireRate[“AK47”] = {Activated = .05, Deactivated = .75}

and then you could reference this by just specifying

FireRate[“GunName”].Activated or FireRate[“GunName”].Deactivated

Ohh now i understand, the only problem is that i will have to insert each one manually, but thats ok. Thanks!