You could use signals to connect from the texture button to the script, you can connect the button pressed and button release, they make it so when the button is pressed it makes a var true and when it is released it sets it to false and then makes
a while loop (or any other thing) to run when that var is true
var pressed = false
pressed = false
pressed = true
while pressed = true: #or if
#Thing you want to run
Though this is a solution, I am going to assume that my way is not the most efficient way.