ID:267262
 
Code :
mob/player/
Click(mob/M)
var/damage = usr.health - rand(0,5)
if(damage <= 1)
usr<<"You attack [M] but misses!"
M<<"[usr] attacks you but misses!"
return
usr<<"You attack [M] for [damage]!"
M<<"[usr] attacks you for [damage]!"
M.health -= damage
M.Death()
mob/proc/Death()
view()<<"[usr] has been killed by [src]!"
usr.loc=locate(18,11,1)
usr.health = maxhealth

Yet it attacks the turf not the mob!
Close your tags at once.
The argument to Click() is the location where you clicked, so that's why that's happening. src is the thing that you clicked on, so use that instead of M.
In response to Jotdaniel
Now how do i like attack within like view(2)?
In response to Master Flame Sage
if(ismob(src))
if(src in oview(2))
...