Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to wait until a bool value = false?

Asked by 6 years ago

Hi there, I'm currently trying to make a script that will set a vehicle seats maxspeed to 0 when it touches a sensor brick which has a bool value inside. The idea is that it would touch the brick and if the bool value inside the brick is false the seats maxspeed will go to 0 and then it would wait until the bool value changes to true at which point the vehicle seats maxspeed would return to its original value. Thanks :)

Here is the current script with the part that I'm not sure how to do written in internal commentary

01local sig = script.Parent.Parent
02local top = sig.Top
03local btm = sig.Bottom
04local debounce = false
05local occupation = script.Parent.BlockOccupied
06 
07script.Parent.Touched:connect(function(Part)
08    if Part.ClassName == "VehicleSeat" then
09        if debounce == false then
10            debounce = true
11            if occupation.Value == true then
12                Part.MaxSpeed = 0
13                --wait until the bool value named "occupation" is false
14                wait(5)
15                debounce = false
View all 29 lines...

1 answer

Log in to vote
0
Answered by
aazkao 787 Moderation Voter
6 years ago
Edited 6 years ago

Use a while loop or a repeat loop that repeats till its false

01local sig = script.Parent.Parent
02local top = sig.Top
03local btm = sig.Bottom
04local debounce = false
05local occupation = script.Parent.BlockOccupied
06 
07script.Parent.Touched:connect(function(Part)
08    if Part.ClassName == "VehicleSeat" then
09        if debounce == false then
10            debounce = true
11            if occupation.Value == true then
12                Part.MaxSpeed = 0
13               repeat
14                  wait()
15                until occupation.Value == false
View all 31 lines...
0
Thank you :) kieranhendy 28 — 6y
Ad

Answer this question