I read somewhere that using :Wait() along with an event would significantly improve performance compared to just using wait(). I'm wondering if the line of codes that i wrote has any difference and which one is more practical?
First code
local number = 0 spawn(function() repeat wait() until number == 10 print('Ten!') end) for i = 1,10 do wait(1) number = number + 1 print(number) end
Second code
local runService = game:GetService('RunService') local number = 0 spawn(function() repeat runService.Stepped:Wait() until number == 10 print('Ten!') end) for i = 1,10 do wait(1) number = number + 1 print(number) end
wait() will try to wait for at least 1/30 seconds but it can wait longer if the game is lagging, whereas Stepped:Wait() will wait exactly a frame You should use Stepped:Wait() over wait() if you can