[CLOSED] How can I change parameter name and type (module scripts)

I have a module script which I wanna use as a “service”. what I wanna do is:
when you use a certain custom enum value the parameter type changes, an example would be:

local Enums = {	
	DebrisType = {
		Circle = nil,
		RandomWithinCircle = nil,
		Jumping = nil
	}
}


local debrisService = {}
function debrisService:Create(EnumType,arg1,arg2,arg3,arg4)
  if EnumType == Enums.DebrisType.Circle then
     arg1 = number --This is basically what I want to do
  end
end
return debrisService

To simplify:

local debrisService = {}
function debrisService:Create(EnumType,arg1 --[[ I want to change this into a number like: arg1:number]] 
,arg2,arg3,arg4)
end

Is there a way to do this?

Your enums need to have unique values. Normally in programming enums are just integers underneath, so for example:

local Enums = 
{	
	DebrisType = 
    {
		Circle = 1,
		RandomWithinCircle = 2,
		Jumping = 3
	}
}

By setting the values to nil you are just getting an empty table so here:

if EnumType == Enums.DebrisType.Circle then

you are just comparing nil to nil

I think you misunderstood. what i want to do is:


I want this arg1,arg2,arg3 to change names depending on enumtype.

are you referring to overloading? currently, there are no information on roblox function overloading; and i believe that its not possible; but there could still be a workaround

oh, damn. thank you for the info.

1 Like