Balancing Huge Array of Valuies

Hello Developers! I have a Huge Module Script that consists of Skills data like: Name,Damage, StaminaCost etc. I’m trying to write a code that will automatically change Certain value in each Skill, for example increase each skill StaminaCost by 1.25.

This is an example of how it looks

local Skills = {
	-- Explosive Flesh

	{
		SkillName = "Explosion Punch",
		SkillIndex = 1400,
		Template = "BasicTemplate",
		Animation = "rbxassetid://18625809676",
		Cooldown = 20,
		DecreaseCE = 19,
		Damage = 24,
		GiveMastery = "OnMobDeath",

		NPCUseState = "Attack",
		NPCUseMagnitude = 5,
	},

	{
		SkillName = "Explosion Jump",
		SkillIndex = 1401,
		Template = "BasicTemplate",
		Animation = "rbxassetid://18604322540",
		Cooldown = 28,
		DecreaseCE = 22,
		Damage = 32,
		GiveMastery = "OnMobDeath",

		NPCUseState = "Attack",
		NPCUseMagnitude = 20,
	},
}

What i’ve tried so far:

  1. I’ve tried this code
local Skills = game.ReplicatedStorage.Scripts.Skills.Skills local reqSkills = require(Skills)
for i, v in pairs(reqSkills) do
	reqSkills[i].DecreaseCE = math.floor(reqSkills[i].DecreaseCE / 1.5) print(v)
end
print(Skills.Source)

Inside the for loop it prints changed value, and when i run this script again it changes the value even more, but when im trying to print the source code to console to copy, it prints the same code as before without changes for some reason.

  1. string.find() function to replace it smh but couldnt do it

  2. string.format() looks like it could help but i didnt really understand how i could make it work for everything

Appreciate any help!

2 Likes

check out the edited pots, i accidentally posted it early so couldnt post everything, i think i already used it and it didnt help

you can do it like this

for _, MoveData in ipairs(reqSkills) do MoveData.DecreaseCe = math.floor(MoveData.DecreaseCE / 1.5) end

im sorry about it looking funky i dont know how to type code in devforum

When i run this code, script.Source remains the same aswell as the script itself

What is script.Source? I don’t find it anywhere in your code.

Edit: Nevermind, I wasn’t aware that was a property.

im just donig print(script.Source) at the end of the for loop to copy the changed code from the console

it wont change the source of the code but everywhere else in scripts where the module is required itll be changed

so how do i get the modified one, so i can replace my old code with the new modified version

ohh so you want to quickly modify all the values
you can just do what i said and then print the modified version in the console copy it and paste it inside of the module

what exactly i should print in the console to get the whole modifed code?

can u show me what you are running in the command bar?

local Skills = require(game.ReplicatedStorage.Scripts.Skills.Skills)

for _, MoveData in ipairs(Skills) do
MoveData.DecreaseCE = math.floor(MoveData.DecreaseCE / 1.5)
end
print(Skills)

you are running your old code again just paste in the one i sent

your are right!

but still i get a lot of arrays like this, i cant just copy and pass it inside my module, i have to manually copy changed property for every skill

btw im using VS Code to write my code, maybe there is a way to do it there? if we cant do it in studio

ill update you in a minute ill open roblox studio to try it

1 Like

if u mean like theres too many arrays and stuff and you have to click the arrows on the side for each one u can do this


press the 3 dots there and turn Show Tables Expanded by Default on
then run the code again and you can just copy the table