How can i make my code run 30 or 60 times per second?

I want to make a script that runs my code 60 or 30 times a second, but i want it to be optimised like i can set the time to 1.3 seconds and the times a second to 30 instead.

The problem i am facing is that i want it to wait in each time so it has to run 30 times for 1.3 seconds.

For example if it has to run 30 times for 1.3 seconds (thats 90 milliseconds) then it would wait in each frame for about 0.03 seconds so it would run exactly 30 time each 1.3 seconds. How could i achieve this?

Any suggestions whould be appreciated!

Put all of your script in this

while task.wait(0.03) do
 --your script here

It’s hard to make, because game always will have lags.