Code only works sometimes

Thanks guys. I’ve changed things a bit and it works great now. I was definately over complicating things.