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

How can i make a script that runs after 20 sec and then work for 140 sec ?

Asked by 3 years ago

so i have a script of 4 platforms that disappear every 20 seconds , how can i make them disappear only 7 times, 140 seconds of work then wait 20 seconds and after it start over the script and do it again only 7 times and so so so here is the script of the 4 platforms:

view source

wait(20) local platforms = workspace.PlatformsFolder -- all the platforms in a folder

view source

colors = { --table of colors
        BrickColor.new("Electric blue"), --Really red
        BrickColor.new("Really red"), --Really blue
        BrickColor.new("Bright yellow"), --Deep orange
        BrickColor.new("Lime green")
        }

while true do
        local color = colors[math.random(1,#colors)]
        print(color)
        for i,v in pairs (platforms:GetChildren()) do
                if v:IsA("BasePart") then
                   if v.BrickColor == color then
                            v.CanCollide = false
                                v.Transparency = 1
                            else
                                v.CanCollide = true
                            v.Transparency = 0
                    end
                  end
        end
    wait(20) --wait however long in between color changes

end

0
pls help xbloodyguyx 10 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Inside the while true loop, you can add a for loop that runs seven times, then a 20 second wait. It'll look something like this

while true do
    for i = 1,7 do
        --Colour change code
    end

    wait(20)
end
0
oh ty , ill try xbloodyguyx 10 — 3y
0
hey , but should i still use the while true do from the color change code or no? xbloodyguyx 10 — 3y
0
If you want it to repeat the process then use the while loop thecelestialcube 123 — 3y
Ad

Answer this question