Basically i have alot of values under one folder in the gun,
And i was wondering if there was a better way to store this information, (Somewhere it can easily be changed)
You could use the Attribute system or store it in a Module.
Some values such as IsReloading
could maybe go in the gun script instead but it isn’t the end of the world. As Dev_Ryan said, a ModuleScript is a good idea to store many values
Seems like a dictionary would solve it good. From the looks of it:
local gun = {
stats = {
ammo = 0,
Damage = 0,
FireRate = 0,
StoredAmmo = 0,
IsReloading = false
},
tiers = {
ReqExp = 0,
CurrentExp = 0,
T1 = "1",
T2 = "2"
T3 = "3",
T4 = "4",
requirements = {
T1 = 5,
T2 = 6,
T3 = 7,
T4 = 8
}
}
To reference values, you’d do something like this:
print(gun.tiers.T4) -->"4"
print(gun.tiers.requirements.T4) --> 8
if gun.tiers.CurrentExp > gun.tiers.ReqExp then [...] end
if gun.stats.IsReloading then
gun.stats.StoredAmmo -= 10
gun.stats.ammo += 10
end
Not entirely sure how to do this, but ill take a look at it
Seems good, although i dont know how i would change it with another script, ect:
Some talent with a 20% chance on hit to remove 10 ammo from the guns mag
To get the values from the module script you’d simply require it and then access the values like it was a property.
local isReloading = require(PathToModule).IsReloading