Glad I could help, plus a slight change in the getPetOwner() function to make it more stable and accurate:
Code:
function getPetOwner(petName)
scanTool:ClearLines()
scanTool:SetUnit(petName)
local ownerText = scanText:GetText()
if not ownerText then return nil end
local owner, _ = string.split("'",ownerText)
return owner -- This is the pet's owner
end
If you don't have the "ClearLines()" then if when you call "SetUnit([name])" and there is no Unit with that name it would reference the old unit called. The second change just makes it so it returns nil if there is no unit with that arg
name passed.
Edit: I think I broke it, I've no idea what's wrong. Working on it...
Edit2: Not broken, actually just remembered
this will only work for pets in your party/raid. (Which was your original intention, right?)
The way the getPetOwner() function is set up now, it will either return the pet's owner if they're in your party/raid or if it is your pet, otherwise it will return
nil