Stuck on figuring out how to call a random module script

Hello! I am trying to develop a FPS mini game using ROBLOX’s new laser tag template. I have two custom maps created and such but I am stuck on this part of the script. The plan is to have it call a Modes module script that will load the map and round data. However, no matter how I rewrite it, I cant get it to call anything other than the TDM module. Taking out TDM from local MODES = { only leaves an error and renaming both to TDM, only loads the first TDM module. The selected script in the image is what the segment of script below is from.
This is my first time working with module scripts and it’s pretty hectic to my basic scripting knowledge. But I want to figure these out and I need some help lol.
image

local remotes = ReplicatedStorage.Gameplay.Remotes
local roundWinnerRemote = remotes.RoundWinner

local MODES = {
	require(script.Parent.Modes.TDM),
}

local random = Random.new()

local function startRoundLoopAsync()
	while true do
		-- Reset scores
		Scoring.resetScores()

		-- Pick mode
		local mode = MODES[random:NextInteger(1, #MODES)]
		local timer = mode.timer
		workspace["Bad Manners OL"]:Stop()
		-- Start the mode, passing in a callback to be called if it finishes early
		local roundFinished = false
		mode.start(function()
			roundFinished = true
		end)
		
		-- Spawn characters
		Players.CharacterAutoLoads = true
		spawnCharacters()

So you want it to randomly choose between the TDM module script and TDMCore module script?

I believe you have to set a randomseed.

local MODES = {
require(script.Parent.Modes.TDM),
require(script.Parent.Modes.TDMCore)
}

math.randomseed(os.time())
local random = Random.new()

-- .....

Firstly yes I want it to be randomly loaded, secondly if I could bother you by asking what os.time means? I’m not home currently but will let you know if works, if it does, I understand putting the second require line in now!

1 Like

Tried out local MODES = {
require(script.Parent.Modes.TDM),
require(script.Parent.Modes.TDMCore)
}``
and it works! Thank you for your help! Now I understand how this part of require in a script like this works. Thanks for your help!

1 Like

os.time() just returns the amount of seconds that have passed since January 1, 1970. So some big number like 158915923

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.