That script doesn’t look all that correct.
I assume your using a ray sensor to simulate bullet fire
Let me try to help you out:
#This is one of my old bullet fire scripts.
#I'll try to comment things as much as I can for you.
import GameLogic as G
cont = G.getCurrentController()
own = cont.getOwner() #getOwner, not sensor.
#When you assign sensors by name like below, you don't put a ""-
#after that. That is done when you call in bulk: "cont.getSensors()"-
#which would pick the first sensor from the top assigned to that object.
#Same goes with actuators.
leftclick = cont.getSensor("LeftClick")
ray = cont.getSensor("Ray")
#Message Actuator that will send a message to the hit object.
#That object would have a health prop and a logic brick setup-
#to decrease the healthprop by (<i>in your case</i>) 30 points, every time
#the message sensor (<i>on the hit object</i>) would recieve a message from
#the kill actuator (<i>which is attached to your player/weapon</i>)
kill = cont.getActuator("Kill")
#Get name of the hit object
obhit = ray.getHitObject().getName()
#Forget "40 frames", measure by time. You can do that by adding a-
#time prop, and you do that by going into the logic brick button window
#and hitting that long ADD property button. Set the property type to "time"
#and name it "time" no quotes.
#Then you call it like this: "own.time"
#Like a clock, it will start counting up seconds as soon as game starts.
if leftclick.isPositive() and ray.isPositive():
#Set a time condition for 2 seconds (<i>or whatever</i>) from fire to next fire:
if own.time > 2:
kill.setToPropName(obhit)#Set message actuator to message this OB
#reset timer to 0, so that the above statement will be false for 2sec
own.time = 0
G.addActiveActuator(kill,0)#Dont's send message/shut down act
I didn’t test this particular timed version, but it should work for you. Play around with it, and if you have any questions don’t be afraid to ask.
PS: I’m glad you decided to take my suggestions. Learning the BGE PY API will help you out plenty, I guarantee it.