Please Help With Tables :((((((((

as you dears know MouseClick Event Returns The Player Who Fired It
so , you can see the script , my problem is in settings.SecretEvents.funcs & args there is my problem , in line 41 where it returns the player who clicks also, i named that arg “plr” .
but , i want to use that plr in settings.SecretEvents.func & args but , i do not now how , i tried many things but didnt get my answer, i do not want to use module scripts too and for the thing
i need i must use settings table instead of just duplicating elseif for secret codes , so id be glad if i can put plr in this func or args table without experiencing an error so id be able to do
such things with the player who clicked it , so help me please(i repeat again , what i want is to access plr who clicks from this table which is at start of the script)

settings={
  TextWhenSuccess=nil,--string
  TextWhenIncorrect=nil,--string
  MaxDigits=nil,--number
  SecretEvents={
    func={[911]=function(player) print(player.Name) end,[1987]=function(e) print(plr.Name) end}, -- problem
    args={[911]={plr}} -- my problem
  }
}
local buttons=script.Parent
local textlabel=buttons.Parent.Part_That_The_SurfaceGui_Is_In.SurfaceGui.TextLabel
local value=''
local function RandomCode(MaxDigits)
  if MaxDigits and MaxDigits>18 then
    return error'Can Not Enter More Than 18 Digits'
  elseif MaxDigits and MaxDigits<=0 then
   return 0
 else
  local vary1,vary2=1,9;
  for i=1,(MaxDigits or 4)-1 do
    vary1=vary1..0;
    vary2=vary2..9;
  end
  return math.random(vary1,vary2)
 end
end
local code=RandomCode(settings.MaxDigits)
print(code)
for i,v in next,buttons:GetChildren() do
  if v:FindFirstChildOfClass'ClickDetector'==nil then
    Instance.new('ClickDetector',v)
  end
end
for i,v in next,buttons:GetChildren() do
  v:WaitForChild'ClickDetector'.MouseClick:Connect(function(plr)
    if (rawlen(value)==rawlen(tostring(code)) and v.Name:lower()~='enter' and v.Name:lower()~='backspace') then
      return
    end
    if v.Name:lower()=='enter' then
      if value==tostring(code) then
        value=''
        textlabel.Text=settings.TextWhenSuccess or 'Correct'
      elseif value~=tostring(code) then
        if settings.SecretEvents.func then
        for i,v in next,settings.SecretEvents.func do
          if value==tostring(i) then
            value=''
            textlabel.Text='Top Secret'
            coroutine.wrap(v)(table.unpack(settings.SecretEvents.args[i] or {}))
          else
            value=''
            textlabel.Text=settings.TextWhenIncorrect or 'Incorrect'
        end
        end
        else
          value=''
          textabel.Text='Incorrect'
        end
      end
    elseif v.Name:lower()=='backspace' then
      value=value:sub(1,rawlen(value)-1)
      textlabel.Text=value
    else
      value=value..tostring(v.Name)
      textlabel.Text=value
    end
  end)
end
2 Likes