I'm guessing you're not setting the Unit GUID correctly.
PHP Code:
local unitguid = (UnitGUID("target") or 0)
local EnemyHP = 100 * UnitHealth("target") / UnitHealthMax("target")
if unitguid ~= UnitGUID("target") or unitguid == 0 then
unitguid = UnitGUID("target")
if EnemyHP > 50 and (not UnitDebuffID("target",1822) or not UnitDebuffID("target",1079)) then
return true
end
end
Try that. Basically; If the current GUID isn't the same as the last unit GUID or if the last unit GUID is 0 (You had no previous target), it'll continue to check if the Enemy has more than 50% health and if Rake or Rip isn't present, it'll cast the ability on the target