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

how to make a script work for a certain time and then wait 20 sec before staring again?

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

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

plsss helpppppp meee

1 answer

Log in to vote
0
Answered by 3 years ago

Should fix your issue.

local platforms = workspace.PlatformsFolder
colors = { 
    BrickColor.new("Electric blue"), 
    BrickColor.new("Really red"),
    BrickColor.new("Bright yellow"),
    BrickColor.new("Lime green")
}
local Ticks = 0
while true do
    if Ticks == 7 then return end
    Ticks = Ticks + 1
    local color = colors[math.random(1,#colors)]
    print(color)
    for i,v in pairs (platforms:GetChildren()) do
        if v:IsA("BasePart") then
            v.BrickColor = color
            if v.BrickColor == color then
                v.CanCollide = false
                v.Transparency = 1
            else
                v.CanCollide = true
                v.Transparency = 0
            end
            wait(1)
            v.BrickColor = BrickColor.new("Institutional white")
            v.CanCollide = true
            v.Transparency = 0
        end
    end
    wait(20) --wait however long in between color changes
end
spawn(function()
    while true do
        if Ticks == 7 then
            wait(20)
            Ticks = 0
        end
    end
end)
0
tyyy imma try it xbloodyguyx 10 — 3y
0
hey dud i still got a problem , they are all white and i cant change it how can i make them remain the same color after disappearing and reappearing xbloodyguyx 10 — 3y
0
ugh :( the script doesnt work xbloodyguyx 10 — 3y
Ad

Answer this question