ID:140819
 
Code:
obj/clothes/var/equipped= 0
obj/clothes/verb/Equip()
if(!equipped)
usr.overlays+= src
equipped= 1
else
usr.overlays-= src
equipped= 0


Problem description:
For some reason it adds the clothing overlay to the player but then it won't take it off afterwards.. Equipped gets set to 0 but the overlay is still there.

I want to do it like this so that the src.layer works for ordering float layers
Normally, that should work fine. Doesn't it work if you run Equip() then immediately run it again to unequip? I can tell you when your code can fail, though (it could also fail to remove the overlay due to issues with overlay saving and loading, but I won't go into that here and you didn't mention saving).

First, for background info purposes, the thing with overlays is that it works appearance-based. As the Reference will tell you, overlays contains visual snapshots in an internal format* - meaning when you add, say, an object, to overlays, that object itself doesn't actually end up inside the list - only a copy of its visual appearance, which is not tied to the object. The same applies to any other value overlay supports to represent appearances with (which includes icon files, /image objects and more).
<small>*: Somewhat contrary to what the DM Reference says, this internal format can be accessed and used in a limited way.</small>

Second, in order to successfully remove an overlay using the standard method, the appearance used in the removal must be completely identical to the appearance originally used to add the overlay. This means if you use an object to add an overlay (like what you are doing), and one of its appearance-related vars changes*, then you afterwards attempt to remove the overlay using it, it won't work, as the object's appearance no longer corresponds to the overlay's.
*: This includes vars like icon, icon_state, layer, and even some unexpected ones such as name, suffix and desc.

Also, note you have designed the equipped var backwards; in a good design the mob should be responsible to keep track of what equipment/clothes/what-have-you he has equipped, not the object itself.
In response to Kaioken
Ohhh wow.. Suffix?.. That's just weird. But thanks Suffix was the problem it changed to "Equipped" but I forgot to put that, thanks for the extra effort in your answer, it paid off!