Hi, i have make a list of a boss in my server, when a player attack a boss i want to check if the specific boss is in the list, i have make this:
1 | local list = { |
2 | "Fox" , |
3 | "Yeti" , |
4 | "Crocodile" , |
5 | "Pharaoh" |
6 | } |
When the player attack the boss i have this condition:
1 | if table.find(list, HitParent) then |
2 | print ( "Rangeboss" ) |
HitParent = the name of the boss when the player attack, so for exemple HitParent = Fox
But the print is’nt fire ^^ maybe my condition is not exactly, somebody have a solution for check the name of the boss in the list ?
Use a for loop to search if the item is in the array. For example, you can do something like this:
1 | for i,v in pairs (list) do |
2 | if v = = hitParent then |
3 | print ( "Hit boss" ) |
4 | end |
5 | end |
Hope this helped!
for this to work, HitParent must be a string value and you can do this:
1 | for i,v in pairs (list) do |
2 | if v = = HitParent then |
3 | print "hello" |
4 | end |
5 | end |
if list[HitParent] then print(HitParent) end