Invalid argument #2 to 'random' (interval is empty) Error when choosing a random function from a table

The code of randomly choosing a function seems to work, however, I still get an error message:
11:43:26.534 ServerScriptService.Events:68: invalid argument #2 to ‘random’ (interval is empty) -
Server - Events:68

I have already looked through the code a few times, and looked through the dev forum but i did not find a person having a very similar code to mine.

Here is the code:

    local functions = {AcidFlood(), FireRain(), GiveSword(), RickRoll()}
    local chosenfunction = functions[math.random(1, #functions)]
    chosenfunction()

Server Script in the ServerScriptService.

the problem is that you are calling your functions inside the table. That leads to the table being empty. You shouldn’t call your functions inside the table like this:

local functions = {AcidFlood, FireRain, GiveSword, RickRoll}
1 Like