Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question