What kind of Lightgun?
Perhaps you don't have the permission to modify or change the mame.ini? You use Windows?
1. Look at your mame.ini. See the date/time.
2, Make the changes, when everything works fine go to your mame folder and make a copy of the mame.ini. The mame.ini is now changed? date/time is changed?
3. reboot and look at your mame.ini again