I have a script with a for loop, how do I time that loop so I know when to call a certain event? Or does it all vary with processing power and technical stuff like that?
I believe what you need is this.
while true do local timeStart = time() --TODO: Finish the loop(aka, other stuff in the loop) wait() --[=[From what I can tell, you must call wait **before** you get the second time; it may help to also call wait before you get the first time because according to the wiki, "wait() must be called for time to update]=] local timeEnd = time() print("Total time is "..(timeEnd-timeStart)) end
I think this might be what you are looking for:
for i = 0, 50 --change the fifty for how long you want the loop to run if i == 5 do print("i is equal to five!") -- put certain event in here wait(1)--currently set to one sec, this is so the timer does not get interrupted else -- if it is not equal to five do this stuff wait(1) -- again set to one sec end end
you mean like this?
while true do --etc... wait(10) end