I didn't manage to replicate your error on the sample project or in another project. It seems to me that the problem is on the Curve Name:
This name cannot be empty or be a number. Otherwise, it will be parsed as a number when it should be a string(text).
So, if it is a number, the method .replaceAll will not work, because this method only exists for strings. When applying to a number this method is undefined, which will cause the error you are getting. So, double check your curve names and see if you have a number or any empty spaces.
If you fix this and still get the error, I will need for you to upload a project replicating the error and send the link here to me, so I can playtest it, trigger the error and see what is happening.