Editing a module at runtime?

Mostly in the title.

In a class-based fighter I’m helping to code, admins (and VIP server owners) have the ability to use commands to create a customized version of any particular class they own. The system itself is simple enough; the default class-changing system has the server send a client a folder to require modules from which contain the class’ attack/ability functions and relevant data. All I need to do is create a temporary copy of the class folder and have the server send the edited copy to the central client instead.

Each class has a ‘MetaData’ module accessible by both the client and server. This module contains information that either side might need for any particular reason. They look like this:

local Abilities = {
	PSV = {
		tooltip = "[PSV]: Battle Spirit - Dealing damage causes the target to drop a healing orb that heals 1 HP and grants 1% CRITICAL.",
		icon = 3637961361,
		maxcd = 0,
		ccd = 0,
		--
	},
	ATK = {
		tooltip = "[ATK]: Brave Blade (0.5s) - Slash with your weapon, dealing 15 damage.",
		altip = "[ALT]: Hero Surge - Perform a spinning cut that deals 20 damage. Activated during Blade Rush. Increases Blade Rush CD by 1s.",
		icon = 2034108791,
		maxcd = 6,
		ccd = 0,
		free = false,
		coolafter = false,
		--
	},
	AB1 = {
		tooltip = "[AB1]: Blade Rush (4s) - Briefly boost speed and jump height. Allows running on water while active.",
		icon = 2034172129,
		maxcd = 40,
		ccd = 0,
		free = true,
		coolafter = true,
		--
	},
	AB2 = {
		tooltip = "[AB2]: Slashing Waves (4s) - Release two waves of energy that deal 6 damage each.",
		icon = 2034172262,
		maxcd = 40,
		ccd = 0,
		free = false,
		coolafter = false,
		--
	},
	CRT = {
		tooltip = "[CRT]: Maelstrom - Release 3 columns of energy that travel forward, dealing 15 damage each to all foes in their path.",
		icon = 4471228632,
		maxcd = 5,
		ccd = 0,
		free = false,
		coolafter = false,
		--
	},
}

local States = {}

return {Abilities = Abilities, States = States}

What I’d like to know is - if I use a function or method of some variety to edit the contents of the table that the module returns, would the changes replicate to other scripts that require it post-edit? Would these changes replicate across the client-server boundary? If not, is there some way I can imitate doing so?

Thanks for reading.

If you make a change on the server to the table, you’ll see those changes on the rest of the server. The same thing applies for each individual client. But it won’t replicate across the client/server boundary. If you want it to replicate, you can write a client script that listens to a RemoteEvent that the server fires and make it update the client’s data based on that.

2 Likes