Problem and Question when making boss attacks

HellO! so I’m making a Boss for my game, Its just a Dummy, But still very epic!!!

So, I made a table for the Boss’s attacks, The issue is I have no idea how Im supposed to return the math.random and find out what it got, I’m doing this so that when we do figure out, I can make the Boss do the attack

Here’s the script rn

local AttackList = {"Stomp", "Punch", "Drill"}

while true do
	wait(5)
	math.random(AttackList[math.random(1, #AttackList)])
end
1 Like

First, you should turn the attack into a variable if you ever want to print the attack or do whatever with it.

Second, remove the first math.random because you are already randomly indexing a key in the table using (pseudorandom number generator), inside the square brackets.

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

Screenshot 2021-08-04 083620

Please explain to me in a more specific way of what part I’m going to have to remove

The first math.random is supposed to be removed? The one that sets everything in the brackets and please look at my example.

1 Like

That’s what Im asking you, you told me to remove the first math.random “because you are already randomly indexing a key in the table”

He already removed it for you.

local AttackList = {"Stomp", "Punch", "Drill"}
local ChosenAttack

while true do
	wait(5)
	ChosenAttack = AttackList[math.random(1, #AttackList)]
end

And that’s what I’m telling you, remove the math.random you used to enclose the line of code. That code is what you should use.

1 Like

so can I just do something like this to do the attacks?

if ChosenAttack == "Drill" then
  Anim:Play()
  ChosenAttack == None
end

Yes. Also change None to " " or nil

1 Like