Unable to require a module function from script stored in a table

So I am having this script:

local eventsModule = require(script.Events)
local eventsTable = {eventsModule.SwordDeathmatch()}
-- This is the part of the script I'm having trouble with.

And I am getting the following error:
Incomplete statement: expected assignment or a function call

I don’t know how to pick a random disaster from the table. Help would be appreciated, thanks!

Require the module before putting its functions in a table. This is just a general good practice to put Service Calls & Modules Requires at the top of the script.

Sorry for the confusion, in the normal script I am requiring the module before creating the table.

Is chosenDisaster a number or a string?

local chosenDisaster = math.random(1, #eventsTable)

Could you show your Module Script? I assume the same error is still printing?

Here it is:

local events = {}

function events.SwordDeathmatch()
	local Players = game:GetService("Players")
	game.Workspace.CurrentRound.Value = game.Workspace.CurrentRound.Value + 1
	for _,player in pairs(Players:GetPlayers()) do
		player.PlayerGui.Main.Main.Text = "ROUND: " .. game.Workspace.CurrentRound.Value .. "SWORD DEATHMATCH"
		for i = 1, 3 do
			player.PlayerGui.Main.Main.Text = "ROUND: " .. game.Workspace.CurrentRound.Value .. "ELIMINATE 2 PLAYERS TO PROGRESS (" .. 3 - i .. ")"

return events

local eventsTable = {eventsModule.SwordDeathmatch()}

‘eventsTable’ should result in an empty table, since eventsModule.SwordDeathmatch() does not return anything. I believe that what you intended looks like this:

local eventsModule = require(script.Events)
local eventsTable = {
   -- Note that the function is only being referenced and not called

-- Select one
local chosenEvent = eventsTable[math.random(1, #eventsTable)]
1 Like