#Help with ModuleScripts

1 messages · Page 1 of 1 (latest)

twilit epoch
#

Im having a hard time understanding how module scripts work because im trying to get a variable from a local script to another local script and make them linked so it has the same variable and it updates both of them when one is changed

flat gulch
#

you can require a module script

#

so like you have a module script in game.ReplicatedStorage named 'Data'

#

and inside data it is

local module = {
  Value = 2
}
#

and in both your local scripts you can refer to the Value by doing

local Data = require(game.ReplicatedStorage.Data)
print(Data.Value)
#

all module scripts are just tables

twilit epoch
#

do i have to require everytime when im changing the value?

proud sundialBOT
#

studio** You are now Level 1! **studio

bleak trail
#

Just do it as Data.Value

#

No need to require again

agile holly
#

Whats a module script