Let's say I want to preform an action 15 times in a second. I want to make sure the action was preformed exactly 15 times in exactly 1 second. How do I do that?
I've tried this:
local oldTime = os.time();
local amount = 15;
local iteration = 1;
while os.time() == oldTime do
wait(1 / amount);
iteration += 1;
end;
print(iteration)
If you don't know what it does, there is a loop that only lasts for 1 second, and it waits 1 15th of a second and adds 1 to a variable until a second has passed
But when I print the variable that was supposed to be 15 from adding, it's almost never 15.
By evenly split out, I mean I want the action to be done all at the same time, I want the actions to be done split evenly out the second.
(I'm doing a different action, not increasing a variable. I just did that for the example)

1 comment
It worked, although I know what a for loop does, no need to explain it to me. I'll mark it as an answer when I figure out how. Nevertheless, you are a legend, thanks.