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?``
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?``
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.
1 comment
If you're trying to make the variable global, use _G. So, _G.ChosenMap