Omg I'm retard. Just add into defined function global r
def functionname(): global rI just didnt see it cause in Lua all var are by standard globals and you need to add 'local' before them to make them local