First, I understand the title of the question is pretty much self-explanatory, but you should describe your question better. For example, what do you mean as a "part" of the script? Is it a method? Are you trying to run a whole section of it? How many approaches have you tried before asking the question?
Now, let's think about the game loop. You know you want to keep repeating a piece of code, so intuitively we can think on writing that code on the game loop (process
or fixed_process
) and have our way on it. But to repeat something every X seconds, we would have to get information on Time spent each loop; we could use Godot timer node, but usually I like to do this on the script I'm working with by simply storing time spent each loop (that's the 'delta' that process
and fixed_process
gives you), and when this timer is bigger than a threshold, reset it and run the piece of code I want. For example:
timer = 0
timer_limit = 1000 # in miliseconds
fixed_process(delta):
..timer += delta
..if (timer > timer_limit):
....timer -= timer_limit
....# REST OF THE CODE