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

How do i use a random value from a script for another script?

I would like to know how a script can use a value from another script. I will need to do this for multiple scripts. Is this possible?

1 answer

✓ Accepted answer

###Yes. This is possible. I think you’re looking for global variables.

###Use a ModuleScript to create global variables, like this:

local module = {}

function module.myFunc()
    print"Hi"
end

module.String = "Hello"

return module

###From your server/local script:

local module = require(game.Workspace.ModuleScript)

module.myFunc()

print(module.String)

###I added a function and a string to the module table.

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