Is it recommended to break multiple long wait()'s?

Im just wondering about the performance impact; when you have a set of unnecessary waits()

assume we have a script that initiates a wait cycle, this initiation could be reinitiated depending on conditions


function loop(newwaittime)
local interrupted = false
--propchangedfunction that sets interrupted to true

task.wait(newwaittime)

if not interrupted return true end
end

assume re/initiated waittimes reach 1000 seconds–and that it could occur lets say 10 times that means i would have 10 task.waits occuring in the background for this one itteration

would it be recommended to just do a for loop and do task.wait(1)'s within and subtract from the total wait time?

the application of the above is to negate unnecessary magnitude checks when the targets are really far away–using physics formula we calculate the quickest possible time for 2 targets to reach eachother before allowing for reconsideration for the magnitude check. problem(?) is a char can change walkspeed or other conditions that would hasten the time, as for slowing down time i dont rly care for it, but everytime a hastening occurs, it leaves the previous wait()'s running. I dont think there is a inherent way to break the waits–nor do I know if it has any impact on performance that would require changes

i did something a little weird but i think it works for my usecase

--globaltweenvar
--initialize numbervalue
--set = 1


--main thread
--playtween after calculations for wait time
while numbervalue~=0 do
   if globaltweenvar then
      globaltweenvar.completed:wait()
   end
end

--seperate triggers cancel the tween and reinitialize it after doing the necessary calculations
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.