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

How to make a loop work when a value changes and then it comes back to its original value?

Asked by 5 years ago
repeat wait() until v.Value == 1

I'm trying to make this repeat every time the value gets to 1.

What's actually happening : It works for the first time then the value changes to 2. When it's 1 again, the script doesn't do anything.

Any suggestions or solutions for this?

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Your script works once since there is no loop to make it work every time. Try this

while true do
    wait(.1)
    if v.value ~= 1 then
        repeat wait() until v.value == 1
    end
end

Hope it helps

0
Thank you! carlito1236 24 — 5y
Ad

Answer this question