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

Do wait() lag your game if overused?

Im not sure if they lag up your game or not. Like if you were for example to use a wait() on a GUI.

while wait() do
	script.Parent.Text = "Money:$".. game.StarterGui.MoneyGui.Frame.Wallet.Value.Value
end

Will this lag up the game if I used it many times on different scripts?

2 comments

0

I'm not sure about that, but it sounds like it wouldn't!

0

while loops will lag your game if you use too many. wait itself does not.

2 answers

✓ Accepted answer

No, having many wait()s will not significantly lag your game, but you can reduce some of the lag by using a Changed event instead of using a while loop to set the text every fraction of a second, like this:

function valueChanged()
	script.Parent.Text = "Money:$".. game.StarterGui.MoneyGui.Frame.Wallet.Value.Value
end

game.StarterGui.MoneyGui.Frame.Wallet.Value.Changed:connect(valueChanged)

1 comment

0

Alright, Ill use this script then. Thank you.

The wait function yields the current thread. It does not "lag", it yields.

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