Question about Variadic potential implementation

Hey, so, I was wondering, instead of having to clog up this starterplayerscript I’ve got with every single effect for everyones client when fired, I’d like to have one thing do it, if possible. I haven’t used them yet, but is there anyway I can use variadic functions to achieve what I’m after? Do I have to try another approach, or how can I get this to work? I simple grab the name and whatever arguements, but it only seems one arguement works, so I can’t do it for all of them. Help and advice is appreciated! Thanks!

game:GetService("ReplicatedStorage"):FindFirstChild("Remotes"):FindFirstChild("SpecialEffects").OnClientEvent:Connect(function(name, args)
require(game:GetService("ReplicatedStorage").Modules.Functionalities)[name](args)
end)

--End of Local Script--

--Segment of Module which grabs this name for example, and the single arguement--

function Commonalities.Pentagram(Summoner)
	local gram = game:GetService("ReplicatedStorage").Assets.Pentagram:Clone()
	gram.CFrame = CFrame.new(Summoner.HumanoidRootPart.CFrame.Position.X, Summoner:FindFirstChild("HumanoidRootPart").CFrame.Position.Y - 3.250, Summoner:FindFirstChild("HumanoidRootPart").CFrame.Position.Z)
	gram.Parent = workspace.IgnoreandClearonEndorStart
	task.spawn(function()
		while gram.Parent == workspace.IgnoreandClearonEndorStart do
			gram.CFrame = gram.CFrame * CFrame.Angles(0,math.rad(3),0)
			game:GetService("RunService").PostSimulation:Wait()
		end
	end)
	for i=0,50,1 do
		gram.Size = Vector3.new(i,.5,i)
		gram.Holder.Temple.ImageTransparency = (1-(i/50))
		game:GetService("RunService").PostSimulation:Wait()
	end
	for i=50,0,-1 do
		gram.Size = Vector3.new(i,.5,i)
		gram.Holder.Temple.ImageTransparency = (1-(i/50))
		game:GetService("RunService").PostSimulation:Wait()
	end
	end
``

I’m not sure I completely understand but are you talking about doing something like this?

game:GetService("ReplicatedStorage"):FindFirstChild("Remotes"):FindFirstChild("SpecialEffects").OnClientEvent:Connect(function(name, ...)
    require(game:GetService("ReplicatedStorage").Modules.Functionalities)[name](...)
end)

Yeah, precisely that, I’m just wondering.

Doing that should work then. When you define the functions that use the arguments, the parameters will be assigned automatically.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.