How to Repeat a Function?

Hello,
I have this function below which makes fireworks go off when an Epoch code (time.os) is triggered. Now say I wanted these same lines of code go off 5 times, (so there are 5 firework blasts) what should I add to the script for this to work? I am new at scripting functions repeats so I am trying to learn how to do this.

function liveEvent()
	for i=1,3 do
		delay(0,function()
			local clr=colors[math.random(1,#colors)]
			local b4c=bang4:clone()
			debris:AddItem(b4c,7)
			b4c.Parent=launcher
			local flare1=flare(launcher.Position,(CFrame.Angles(math.pi/2,0,0)*CFrame.Angles((math.random()-.5)*.5,(math.random()-.5)*.5,0)).lookVector*100,.8,2)
			flare1.RotVelocity=Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*100
			local b=makerandombang()
			b.Parent=flare1
			wait()
			if b4c then
				b4c:Play()
			end
			wait(2.5)
			if flare1 and b then
				b:Play()
				for i=1,7 do
					local f=flare(flare1.Position,(launcher.CFrame*CFrame.Angles((i/7)*math.pi*2,0,0)).lookVector*20,.95,3,clr)
					if i==7 then
						local s=Instance.new("Sound")
						s.Volume=1
						s.SoundId="http://www.roblox.com/asset/?id=160247625"
						s.Pitch=.5
						s.Parent=f
						wait()
						if s then
							s:Play()
						end
					end
				end
			end
		end)
		wait(math.random(3,6)*0.1)
	end
end
1 Like

Wouldn’t it just be a for i=1, 5 do loop with a wait? Then it runs 5 times.

1 Like

I made an open-source firework/countdown system if you want to use it.

1 Like