#variable saving with module script

1 messages · Page 1 of 1 (latest)

humble sluice
#

is it possible for me to create a variable in a module script, that the variable is then used in all the other scripts after i use that function in a different script?

module script code:

local module = {}
function module.scientificdisp(amount)
local val = math.floor(amount/(10^math.floor(math.log10(amount)))*100)/100 .."e"..math.floor(math.log10(amount))
print(val)
return val
end
return module

other script code:

local module = require(game.ServerScriptService.ModuleScript)
while task.wait(0.2) do
if game.ReplicatedStorage.Nothing.Value > 9 then
module.scientificdisp(game.ReplicatedStorage.Nothing.Value)
print(val)
script.Parent.Text = val
else
script.Parent.Text = game.ReplicatedStorage.Nothing.Value
end
end

exotic spruce
#

yes modulescript lets u use shared values over different scripts

#

just do module.example = "example" and u can access this value in scripts where u require the modulescript