Firework launch system help

Right, I’m trying to make a firework launch system that will launch all the fireworks in the game at the same time. Right now it will just cycle through all of the parts in the workspace and I need it to launch them all at the same time. I can do this will several scripts but I’d like it into one so updates can be quicker. I found the code to cycle through on devforum btw.

local event = game:GetService("ReplicatedStorage").Launch

local function firework()
	for index, object in next, game.Workspace:GetChildren() do
		if object:IsA('Part') then
			if object.Name == 'Firework' then --Name of the firework models is "Firework"
			--Launch fireworks
		end
	end
end

event.OnServerEvent:Connect(firework)

you could add them on a table and then after the initial loop is done run another one firing every firework at the same time like:

local event = game:GetService("ReplicatedStorage").Launch

local function firework()
    local fireworks={}
	for index, object in next, game.Workspace:GetChildren() do
		if object:IsA('Part') then
			if object.Name == 'Firework' then --Name of the firework models is "Firework"
			--Launch fireworks
		end
	end
    for i,firework in pairs(fireworks) do 
       --idk how you're doing fireworks so considering they have a bindable inside of them
      firework.Bindable:Fire()
    end
end

event.OnServerEvent:Connect(firework)

Do you mean the part name of the firework inside the table?

I meant, how are you launching them? do every firework have a script inside of them that listens for some bindable in the firework instances or you still dont have any way to move them at all?

So, v1 had a script in each of them but I didn’t want to have to change every script if I updated something so I’m trying to migrate it to a single script to launch them all at the same time. Now I’ve put all the fireworks into a folder if that helps.

Being honest with you that comes with a price though. the more fireworks you have the slower it will take to update, for example 30 fireworks would already be a lot thus making their movement very very slow, so i’m not sure a single script is a good idea, maybe you could handle them on the client so you can actually use a script per firework without having to worry for the server’s fps

Would copying one script into all of the fireworks on server start up work better? I’d edit the one that gets copied as a master.

well sure that could work, helps to organize stuff too.

Kk will try that then ig. Thanks for the help anyways.

I can copy scripts from script service right

Yes if the script that’s copying is a serverscript then it should work.

yeah this works really well, thanks

1 Like

Use the collection service. You will only need one script for every fireworks and not one in every of them