Which is more efficient?

Recently I’ve been heavily looking into performance and how to make my game run better, and I’m using a while true loop and I was wondering if this alternative would help efficiency wise.

The Alternative

local function WhileTrue()
	--Code Here
	task.wait(15)
	WhileTrue()
end
WhileTrue()

or

While True Loop

while true do
	--Code Here
	task.wait(15)
end

There is no difference in efficiency, however I recommend using the local function method, this way you can call the loop whenever you want, while the second one will only happen when the script is first run and will yield the whole script forever. If you want to make other processes happen while the loop is going, use coroutines to create new threads

1 Like

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