Hi. I created a weapon that increases its stats the more you use it. I made a level system that constantly checks if the player has enough EXP to increase the guns stats. It works fine and all, but I feel like im stressing out the server by constantly changing the ModuleScript for the gun stats even though its the same one. I wonder if theres an alternative method that’s not too stressful for the server to handle.
Currently, im using this method:
--Weapon Info ModuleScript, where the rank requirements are stored and other things
local Info = {
NormalMesh = "rbxassetid://95387789",
GoldenMesh = "rbxassetid://126534866",
LevelEXP = {
[2] = 500,
[3] = 1250,
[4] = 2000,
[5] = 3000,
[6] = 4000,
[7] = 6500,
[8] = 8000,
[9] = 10000,
[10] = 12500,
[11] = 15000,
[12] = 18000,
[13] = 21250,
[14] = 25000,
[15] = 30000,
[16] = 32847234,
}
}
return Info
The reason rank 16 is alot higher than the others is that i plan for Rank 15 to be the max rank.
Heres the code that runs everytime a player hits a target
p.GunEXP.Value = p.GunEXP.Value + exp
local wepinfo = require(game.ServerStorage.WeaponStats.Luger.Info) -- Info ModuleScript, seen above
local val = p.GunEXP.Value
local rank
for i,v in pairs(wepinfo.LevelEXP) do
if val >= v and wepinfo.LevelEXP[i+1] > val then
rank = i
print("Ranked up! "..i)
local newmodule = game.ServerStorage.WeaponStats.Luger["LV"..rank]:Clone()
wep.Stats:Destroy()
newmodule.Name = "Stats"
newmodule.Parent = wep
end
end
After ranking up once, The print command runs every single time the player hits a target, meaning it will also constantly replace a new modulescript for the gun. Im worried it might stress the server too much, especially if im dealing with a full auto weapon. Is there an alternative way to make a Leveling system(with a cap) without repeating unnecessary code?