Passing arguments from a module script to a fireclient event, gives me error

hello im having a issue for passing arguments in a fireclient, here is how is passing out.
and i dont know how to solved, here is how i order it, if someone helps me to understand and help me solve the error

the arugments itself:

local dmdn = {}
--hitbox and dmg modules
local raycast = require(game.ReplicatedStorage.RaycastHitboxV4)
local damage_handler = script.Parent.Parent.Parent.Damage_Handler

local function damage(witch: "cummunhit" | "pull" | "bethit" | "blockhit" | "breakblockhit" | "perfectblockhit" | "misshit", ...)
	damage_handler:FireServer(witch, ...)
	print("aadasd")
--this is the damage deal and other shenanigans, not very important for the topìc
end
print("AAA")
--arguments:
function dmdn.dmg1(player, combotype, dmg, debtime, bodyfdire, soundid, partt, cframee, sizee, strongornah, ragdoll, stuntime)
--code stuff that is not important for this topic
end

return dmdn

first passing arguments:

local dmgstype = require(script.TypesOfDamages.hitbox)

local dmgscript = {}

function dmgscript.new(player)
	local cratething = {}

	function cratething:FirstType(...)
		dmgstype.dmg1(player, ...)
	end
	
	return cratething
end

return dmgscript

bindable event for passing the arguments to the remote event for client:

script.Parent.Event:Connect(function(player, d, ...)
	local module = require(script.Parent.Parent.Hitbox_Call)
	if d == "damage1" then
		local newd = module.new(player)
		newd:FirstType(...)
	end
end)

the remote event:

game:GetService("ReplicatedStorage"):WaitForChild("Combat").Hitbox_Handler_Remote.OnClientEvent:Connect(function(plr, something, ...)
	local module = require(script.Hitbox_Call)
	print(something, ...)
	local bruh = script.Event
	bruh:Fire(plr, something, ...)
end)
local function hitbox(wich: "damage1" | "damage2", ...)
	Hitbox_handler:FireAllClients(player, wich, ...)
	print("d")
end

--*some event to shoot the function*

task.spawn(function()
	local hitboxtable = {
		"all",
		1, 
		1, 
		rot.CFrame.lookVector * 40, 
		"rbxassetid://6978814463", 
		rightarm, 
		CFrame.new(0,0,1), 
		Vector3.new(5,5,5), 
		"normal", 
		true, 
		1
	}
	hitbox("damage1", hitboxtable)
end)

and here the error that gives me on the output:

i really dont know what im doing wrong, its my first time using the 3 dots (…) on a argument and use it tbh.

and here is how is orded the scripts:
image
(is on ReplicatedFirst all those script)

heloo??? :moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai::moyai:

instead of using the … why dont you make the callback hitboxtable?

1 Like

wdym by that?, explain it
skull-issues

local function hitbox(wich, hitboxtable)
	Hitbox_handler:FireAllClients(player, wich, hitboxtable)
	print("d")
end

hitbox("damage1", hitboxtable)
1 Like

that just make the whole argument stuff like useless

You probably have to use hitbox("damage1", table.unpack(hitboxtable)). However, if your dmdn.dmg1 function has 12 parameters, you should probably just pass arguments in a single dictionary or array and forget about using variadic functions.

1 Like

but idk why you would have used … in the first place? that is normally used if ur passing multiple data for example:

-- module that handles fireing events
module.FireClient(player, eventName, ...: any)

-- ur script
local module = idc
module.FireClient(Player, 'Britney Spears', 'mm2', 'nikedinvike')
1 Like

sometimes module script can’t fire all clients or simply one client, experiment with normal scripts instead of trying to do it inside module, maybe the problem is that something didn’t load correctly

1 Like

hitboxtable is one argument, and in ur hitbox function, you’re expecting to accept more than one argument with the …

You need to pass hitboxtable as

table.unpack(hitboxtable)

Or you can just pass the table itself, and make sure every function expects the table, instead of using …

1 Like

its for making the scripting writting more easly and not copy and paste the same arguments over and over agein, basicly making the script more smooth on my way

okey okeyyyyyyyyy, i mean now its working know that i read the reply @Content_Corrupted019 and yours, using the table.unpack(hitboxtable) in the function, thanks nwn

okey okey nwnnn, did work actually, thankss!!!

well i mean, i just want to make the project more clean, and yknow, less connections and stuff, make it more optimizated??

1 Like

it depends, clean code can be laggy but readable, but sometimes the best option is to ask yourself, is it really needed?, for example, data store system are controlled almost 100% by you, soo why you need check if table that is always the same are correct or not?

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