I'm rather new to 3d Gamestudio too so I might not be much help. My advice will mostly come in the form of suggestions, not exact code because, well simply I don't know the exact codes.
For the bullet to launch out of the gun you need to make a pointer for the gun, preferably name it gun. Then when you use ent_create place the bullet at something like, x = gun.x + 30; y = gun.y + 10;. You will have to use MED to find out how many units away the bullet should be placed at. I think you can also create a vertex where you want the bullet to spawn on the gun, then using ent_create set the creation point to that vertex somehow.
For the bullet hitting the target part, I imagine you would have to use some type of event_collision function, as well as variables such as health -= 5; or something like that so that on collision the bullet does 5 damage.
Sorry I can't help you so much with the code, but I hope the ideas provided will be beneficial.