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

Repeat until keep's crashing studio?

Asked by 8 years ago

I am trying to make this work until the BoolValue's value is changed to false, but it keep's crashing my studio even with a wait. Can someone tell me how to fix it?

Here is the code.

val = script.Parent.on -- BoolVaue
g1 = script.Parent.G1 -- Model

val.Changed:connect(function()
    if val.Value == true then
        repeat until val.Value == false
        wait(0.02)
        for _,v in pairs(g1:GetChildren()) do
            if v.Name == "Light" then
                v.Point.Enabled = true
                v.Lighto.Enabled = true
                wait(0.02)
                v.Point.Enabled = false
                v.Lighto.Enabled = false
                wait(0.02)
            end
        end
    end
end)

1 answer

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago

Repeat until loops take the following structure:

--[[
repeat
[chunk]
until condition
]]

On line 6, you create a repeat until loop, with no chunk. In other words, you didn't put a wait time for the loop.

To fix, do the following:

repeat wait() until val.Value == false
0
Thanks. ISellCows 2 — 8y
0
Yup Validark 1580 — 8y
Ad

Answer this question