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

How do I make a timer for fireworks so that it goes off every 180 seconds?

Asked by 6 years ago

How can I make a timer for fireworks? I have this so far:

PARTE = script.Parent.America
wait(7)
script.Parent.Anchored=false
wait(2)
script.Parent.Anchored = true
script.Parent.Transparency = 1
PARTE.Enabled = true
wait(.5)
PARTE.Enabled = false
wait(2)
script.Parent:Destroy()

I want to make it that every 180 seconds the firework goes off again.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Use a while loop. This is a type of loop that will run until the given condition is false, so by making the condition always true, you can make it run infinitely.

while true do
    -- fireworks
    wait(180)
end

Note that if your infinite while loop does not have a wait in it, it will crash your game.


EDIT: This is what it should look like:

while true do
    PARTE = script.Parent.America
    wait(7)
    script.Parent.Anchored = false
    wait(2)
    script.Parent.Anchored = true
    script.Parent.Transparency = 1
    PARTE.Enabled = true
    wait(.5)
    PARTE.Enabled = false
    -- I removed the destroy part since it would stop the code from running more than once
    wait(180)
end

Hope I helped!

~TDP

0
while wait(180) do thesit123 509 — 6y
0
It did not work :C what exactly should my script look like all together then? TheBeaver101 28 — 6y
0
Edited. thesit, that is a bit more complicated (in terms of understanding how it works) so I didn't do it that way. TheDeadlyPanther 2460 — 6y
0
It works except there's two problems. There's body velocity so when it repeats it continues to go up, and it stays transparent. Is there a way to maybe make it so every 180 seconds it regenerates? TheBeaver101 28 — 6y
View all comments (3 more)
0
To do that you would clone the original firework every 180 seconds and light it of Sekant 20 — 6y
0
You could save the firework's position the reset it when it's finished. TheDeadlyPanther 2460 — 6y
0
You could save the firework's position the reset it when it's finished. TheDeadlyPanther 2460 — 6y
Ad

Answer this question