Getting a different outcome from math.random every time a function is called

I’m trying to make a system that every time a function is called I get a different value from math.random.
I’m using this to get a different attacks for NPCs in a turn-based RPG game but I have no idea how to set up a loop that gets me a different value.
I tried for loops, repeat until loops and I get 2 different outcomes
1 - it repeats the attack over and over
2 - it doesn’t do anything while the attack is supposed to run

I have since removed the loops to hopefully be easier to understand
code –

function enemyMovePicked()
	local event_index =  math.random(#enemyMoveSetRandom.enemy)
	local event = enemyMoveSetRandom.enemy[event_index]
	local event_f = event.attack

	if chosen ~= event.ATTACK_NAME and stop == false then
		event_f()
		stop = true
		wait(1)
		stop = false
	end
	
	chosen = event.ATTACK_NAME
end

(enemyMoveSetRandom is a module script)

How would I do it in a way to get a different outcome?
Code examples or fixed versions will appreciated!

how is enemyMoveSetRandom.enemy structured?

Basically a table with 2 tables containing a attack function and the attack name

You’re calculating a random value between #enemyMoveSetRandom.enemy, and nothing.
Math.random is bounds, so do 1,X instead of X.

Also, if enemyMoveSetRandom is a table with 2 tables as children… #enemyMoveSetRandom will be 2, which means you’ll still only get 2 different values

local attack = attackTable[math.random(1,#attackTable)]