Wait() not waiting

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like to make a wait until the variable Finished becomes true

  2. What is the issue? Include screenshots / videos if possible!
    The wait command doesn’t wait :frowning:
    It prints “finished” even tho the variable is false

local DoYouWant = game.ReplicatedStorage.UI.NiceToMeetYou.Texts.DoYouWant:Clone()
local Yes = DoYouWant.Yes.TextButton
local No = DoYouWant.No.TextButton

local Finished = false

No.MouseButton1Click:Connect(function()
--code
end)
Yes.MouseButton1Click:Connect(function()
	Finished = true
end)

wait(Finished == true)
print("finished")

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    tried looking around, found nothing

repeat wait() until Finished == true

← my honest reaction

2 Likes

That’s not how it works lol.
You want to just do Yes.MouseButton1Click:Wait().

Also use task.wait() instead of wait(), it’s generally much better.

HAHGAHAHAGAH thanks @Mister33j

task? how does task works? @TestyLike3

wait() is deprecated, and it doesn’t guarantee that it’ll run on the next frame after the given delay (or the frame directly after if there is none given).
task.wait() will guarantee that it WILL run on the next frame after the delay, because it uses the Task Scheduler. The task library also comes with a few other cool things, but task.wait() is (in my opinion) the best.

Where did you get this from? create. roblox .com doesn’t mention that.

Come again?

This is the page I got it from.

With show deprecated unticked, wait still shows. Wait also does not have any yellow underline in the script editor. I guess they just forgot to change those?

1 Like

It’s so widely used they might (keyword, might) just be giving people time to figure out on their own, and then eventually giving out a notice, then updating it in all occurrences.
Let’s stop bumping this now though.

1 Like

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