ID:140850
 
Code:
turf
Click()
for(var/mob/unit/B as mob in usr.selected)
walk_to(B,src)
mob/unit/
Click()
if(src.s==1)
if(src.onwer!=usr)
usr<<"You cant select units that dont belong to you!"
return
usr<<"You unselected [src]"
usr.selected-=src
var/icon/I=new(icon='aaa.dmi'+"[usr.red]",icon_state="1")
src.overlays-=I
src.s=0
else
if(src.onwer!=usr)
usr<<"You cant select units that dont belong to you!"
return
usr<<"You selected [src]"
usr.selected+=src
var/icon/I=new(icon='aaa.dmi'+"[usr.red]",icon_state="1")
src.overlays+=I
src.s=1


Problem description:
Edited: It wont move and when i try to unselect(clicking second time) it says:

runtime error: type mismatch: Worker (/mob/unit/Worker) -= Worker (/mob/unit/Worker)
proc name: Click (/mob/unit/Click)
usr: Karffebon (/mob)
src: Worker (/mob/unit/Worker)
call stack:
Worker (/mob/unit/Worker): Click(the grass (11,19,2) (/turf/grass), "default.map1", "icon-x=15;icon-y=21;left=1;scr...")
You unselected Worker

You need to initialize selected as a list. So, mob/var/list/selected = list().
In response to Garthor
lol, it worked , thanks i made selected[] before
You might also want to change the way you handle unit selection. You could also track their selection overlay (if that's what it is) by saving it as a reference.

mob
var/list/selected=list()
unit
var/icon/selection_overlay //Use a referece variable to keep track of their selection overlay.
Click()
if(src.owner==usr) //Spelled owner
if(src in usr.selected) //Check to see if the unit is in a a list of selected units.
usr<<"You unselected [src]"
usr.selected-=src
src.overlays-=src.selection_overlay
else
usr<<"You selected [src]"
usr.selected+=src
src.selection_overlay=new(icon='aaa.dmi'+"[usr.red]",icon_state="1")
src.overlays+=src.selection_overlay
else usr<<"You cant select units that dont belong to you!"