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:
local list = { "Fox", "Yeti", "Crocodile", "Pharaoh" }
When the player attack the boss i have this condition:
if table.find(list, HitParent) then 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:
for i,v in pairs (list) do if v == hitParent then print("Hit boss") end end
Hope this helped!
for this to work, HitParent must be a string value and you can do this:
for i,v in pairs(list) do if v == HitParent then print"hello" end end
if list[HitParent] then print(HitParent) end