Why is my code only reading the first condition and not checking for the second?

63 Views Asked by At

Why is my code only reading the first condition and not checking for the second condition on my code.

def primary():
    if keyPress.positive:    
        if raySensor.hitObject['primaryWeapon']:
            own['primary'] = raySensor.hitObject['weaponName']
        elif raySensor.hitObject['secondaryWeapon']:
            own['secondary'] = raySensor.hitObject['weaponName']

primary()            
1

There are 1 best solutions below

0
On

After a day. Finally I've found a solution. It think the problem is with me using Boolean instead of a string. It got me thinking so hard and I had to try out a lot of ideas on how to fix this. Anyway thank you guys for you participation.