Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I connect multiple function to a single event like so?

https://i.imgur.com/wLGCbYV.png

Picture of the tool I am using, ignore anything outside of the blue squares

context: I am making a potion script using a module script in a tool. Each potion tool is given certain effects in the folder named "Effect", which has string values. The variables for the effect is found under the configuration folder, and in the folder of the respective effect's name.

This is what is in the module script named "gamescript"

ptypelist = {health = healtheffect(),strength=strengtheffect(),speed = speedeffect()} -- The functions here are from the module script. Each of these functions require two parameter, the character, and the configuration folder

	function gamescript.potiondrink(chr,effect,config) -- "chr" is Character of the player, "effect" is the folder "Effect", "config" is the configuration folder.
		local t = {} -- Container for the list of effect functions
		for i,v in pairs(effect:GetChildren()) do
			table.insert(t,1,ptypelist[v.Value])
		end
		for i,func in pairs(t) do
			chr:FindFirstChildOfClass("Tool").Activated:connect(function() 
				--[[plays the function in table "t"]]--
			end)				
		end
	end

1 answer

✓ Accepted answer
ptypelist = {health = healtheffect(), strength=strengtheffect(), speed = speedeffect()}

function gamescript.potiondrink(chr, effect, config) -- "chr" is Character of the player, "effect" is the folder "Effect", "config" is the configuration folder.
    local t = {} -- Container for the list of effect functions
    for i,v in pairs(effect:GetChildren()) do
        table.insert(t,1,ptypelist[v.Value])
    end

    chr:FindFirstChildOfClass("Tool").Activated:connect(function() 
        for _,f in pairs(t) do
        	f(config or whatever args here)
        end
    end)               
end


This discussion is preserved as it was. New answers, comments, and votes are closed.