Really simple problem with if statement, it runs even when false.

def main(cont):
forward = cont.sensors[“forward”]
run = cont.actuators[“run”]
SwordDrawn = cont.owner[“SwordDrawn”]

if forward.positive and SwordDrawn == False:
    cont.activate("run")

The activator continues to run even when forward is no longer true. This is my first post and I’ve lurked the forum for a long time without finding anything valuable on this particular problem. I’ve also seen the talent of you guys here so I’m sure one of you will have a great idea to fix this.

have you checked, that forward really isn’t true?
Is the indentation in your code correct?

it’s better to use:

if forward.positive and not SwordDrawn:

but doesn’t change the behavior

got it working but through a workaround;

if not forward.positive:
cont.deactivate(“run”)

Thanks for your time and suggestions though :slight_smile: