Well, you have multiple ways to achieve this. One way is to require a module script and use the data inside. We can do that because module scripts are formed as a table that is returned as the final statement.
-- Module script:
local module = {}
-- This value is private and is accessible to module script only.
local otherValue = 50
-- This value is available when your require the module.
module.yourValue = 100
return module
-- Server script:
local module = require(script.ModuleScript)
local yourValue = module.yourValue
-- The following is written with preposition that value is already rapidly
-- being changed in the module script.
-- Example 1:
for i = 1, 10 do
print(yourValue) -- prints same stored value
wait(1)
end
-- Example 2:
for i = 1, 10 do
print(module.yourValue) -- prints updated values
wait(1)
end
There’s many methods to use module script to return values. Either you use a simple require() or variable it with a function, although these are easily replacable by writing them in the main script.