Fix a bug of isLastchar
Change the scope of the function to be scriptlocal