Hello friends, I'm trying make my creature target a player that is not a tank.
What I did here is select all targets from top aggro to bottom. In this case there were 3 targets counted in total. Index starts at 1 so skipping the top aggro tank I start at 2 with math.random. I printed it and it returns either 2 or 3. For some reason it sometimes finds a target and else its nil but when it does find it, it appears to always be the same player there are 2 non-tanks in this case. Am I missing something here?
local targets = creature:GetAITargets()
local target = creature:GetAITarget(1, true, math.random(2, CountTargets(targets)))
local count = 0
for _, v in pairs(t) do count = count + 1 end
PS I know of the GetAITargetsCount method but it returns a userdata (don't know this datatype) not a number and it doesn't convert with tonumber so can't be used in math.random.