Hi @eyas,
Welcome to the UR community!
Your issue is that URScript variables cannot change type. It looks like you initiated it with an integer.
So I would suggest you make the createGlobalVariable(String) method instead of createGlobalVariable(String, Expression)
Hope that solves your issue.
Best regards
Ebbe