Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Copying data between modules?

I need help. I need to copy data between two (maybe more) ModuleScripts.

Basically, I have two modules. One stores a long list of, for this example, parts, and the other only has one part in it and functions as a "Template." These are using dictionaries, which I am not well-versed in, so please help. Example: Module 1:

local module = {
	["Part1"] = {
		["Size"] = 0
		["Position"] = 0
		["Direction"] = 0
	}
	
	["Part2"] = {
		["Size"] = 0
		["Position"] = 0
		["Direction"] = 0
	}

	["Part3"] = {
		["Size"] = 0
		["Position"] = 0
		["Direction"] = 0
	}
}

return module

Module 2:

local module = {
	["Part4"] = { -- THE DATA I WANT TO COPY INTO MODULE 1
		["Size"] = 0
		["Position"] = 0
		["Direction"] = 0
	}
}

Server Script:

local module1 = require(script.Module1)
local module2 = require(script.Module2)

--??

Basically, I want to copy the data (In this case, Part4) from Module 2 to Module 1. I have no clue on how to even start. Please help.

1 comment

0

Side note: My game relies on this module system to work, and is built around it. It would take pretty much rewriting all the code to change the system.

1 answer

try this, it might work

local module1 = require(script.Module1)
local module2 = require(script.Module2)
module1[#module1+1]  = module2[1]

1 comment

0

if it no work, replace module2[1] with module2["Part4"]

This discussion is preserved as it was. New answers, comments, and votes are closed.