Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Faster repeat method than while true do?

I have programmed a world generator and

while true do 
wait ()

end

already generates too much delay and ensures that the world is generated very slowly

7 comments

0

You don't need to wait() after every iteration. You can do 10, 20, even 100 at a time without any problems. Just make sure it does eventually wait or it will hang.

1

Use a hearbeat wait?

0

Loading in chunks is definitely the way to go for this.

0

Absolutely chunks imo if your doing any kind of terrain generator

0

Unless you mean just the loading, in which case you can look into Network StreamingEnabled but read up on it because it effects a lot in local scripts

0

Take a look at RunService's Events => https://www.robloxdev.com/api-reference/class/RunService. And indeed, the above user''s suggestions are highly recommended. Nevertheless, the answer to your question can be found in RunService's Events; Stepped, Heatbeat or RenderStepped

0

A "faster" method without a wait will crash the server if it's a infinite loop.

1 answer

local amount = 0
local MaxAmount = 20 -- 10,20,100
while true do
if amount+1 > MaxAmount then
amount = 0
wait() -- Set Amount
return
end
amount = amount+1
if amount == MaxAmount then
amount = 0
wait() -- Set amount
return
end

-- Do rest


end

4 comments

0

Idk if this is what u were looking for but its what i thought u were so

1

nice explanation

0

cool. I once did this accidentally with it going 1000 times before wait () and my frames per second went down to like 1/2 but it didn't hang. Really annoying.

1

please properly indent your code.

This discussion is preserved as it was. New answers, comments, and votes are closed.