Scratch oddities

I have been trying to find a way for a Scratch Sprite to jump, so that it is possible to go and build platform type games for example.

Having looked around the solution presented here appears to fit what I wanted to do. However a modified version can also be found here. The main code block for jumping is below.

My attempt to integrate this in to my own project, keeping the code pretty much the same other than modifying the colours that the sprite is touching.

This appears to allow the sprite to jump, return back down again (due to gravity) but then the game stalls and the jump variable keeps on counting down. I set the variable to display on the stage so that I could keep an eye on it. Where as the code in the previous project works properly and allows jumping. I can’t at present see what has changed, especially as the whole block of code was copied over.

So in essence, copying code to the backpack, then in to another project causes something to go wrong.