The custom blocks were interfering with the speed so I removed them from the code and now it works without any lag.
I am not sure if this is due to Scratch 3.0 running different than Scratch 2.0 but it may be the case. @TheBoogieKing