Code:
/player
var list/targets[] = list()
var max_targets = 3
proc
set_target()
rem_target()
set_target(var/player/o)
if(o in targets)//if the target is already i the list.
return
var/image/target_icon = image('target.dmi', o)
if(o.client && o) if(targets.len == max_targets)
src.targets.Remove(pick(src.targets))
src.targets.Add(o)
o.overlays.Add(target_icon)
src << target_icon
rem_target(var/player/o, var/image/target_icon)
if(o in targets) for(target_icon in src.overlays)
src.overlays.Remove(target_icon)
src.targets.Remove(o)
What you are doing there is wrong since src.overlays doesn't contain image objects. But I'm sure what you were trying to do was specifically remove the target_icon image created in set_target(), which isn't the right way to go about it (see beginning of post).