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

how do you take a certain part of a script and put it in another?

i have used the script:

local ChosenMap = Maps[math.random(1,#Maps)]

to choose a map at random in my first script, how do i take that map and put it into a different script?``

1 comment

0

If you're trying to make the variable global, use _G. So, _G.ChosenMap

1 answer

Hello, you can put it in a module script and require it by another script. In the Module Script:

local mapTable = {}

return mapTable

In your original script:

local mapTable = require(script.Parent.ModuleScriptName)

mapTable.randomMap = Maps[math.random(1, #Maps)]

In the script that you want to get the map:

local mapTable = require(script.Parent.ModuleScriptName)

local chosenMap = mapTable.randomMap

Hope this helps!

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