So I have a D3100 and I always wondered what that little thing is (see photos) There is a little plastic thingy sticking out on a lens mount, it is spring-loaded like a button so I can press it, but as far as I can tell it isn't even pressed when I put a lens on. I tried to press it with lens on & off but didn't notice any effect. Note that it isn't the pin that keeps lens in place. I noticed it on other nikons as well.
That is the EE servo coupling switch. This is only for use with older lenses (non-G AF lenses). Modern AF-S G lenses don't have an aperture control ring (it's completely controlled by the camera body).
When a non-G AF lens is mounted, the tab on the lens engages the switch on the camera when the lens's aperture ring is stopped down to is minimum aperture setting (such as ƒ/22 or ƒ/32, depending on the lens). This is lets the camera know that it has full control range of the lens's aperture. Any setting of the lens aperture ring wider than minimum means the camera cannot physically stop the lens down lower (smaller) than the number on the aperture ring. For instance, if the aperture ring were set to the widest aperture setting (say, ƒ/1.4 on the AF 50mm 1:1.4D), then the camera would not be able to change the lens's aperture at all.
If you mount a non-G AF lens to your D3100, the camera will tell you when the aperture isn't stopped all the way down: it will give you a
fEE error, and won't let you shoot until you stop the lens aperture ring all the way down. See: Why is my Nikon 50mm f/1.8 giving me an fEE error?
It’s simply used to set automatic aperture (af) in older lenses. If you use manual aperture, using the aperture ring and speed as you should if you want to learn actual photography, it doesn’t serve any practical purpose.
A recommendation learn to shoot in manual (setting manually the speed, ISO, aperture and focus) and forget about the actual mechanics of the camera and it lenses, unless you want to become a camera repairman.
Nowadays most digital photographers actually care most about bragging about their digital cameras that being able to take a decent shoot how they would actually wanted and not how the camera wanted it.
For the latter I would advise anyone to buy an iPhone 11 Pro, save a few bucks, while getting an automatic camera with much better AI than any pro camera on the market today and in the foreseeable future and on top of it you’ll get one of the best, if not the best, smartphone in the market.