Attempt to call a string value

if cmd:lower() == prefix.."pbanlist" then
    local pages = datastore:GetSortedAsync(false, 100)
    local bans = pages:GetCurrentPage() 

    local gui = script.Guis.PbanGui:Clone()
    gui.Parent = player.PlayerGui
    for i,v in pairs(bans) do  
        local key = v["key"]
      local success, err = pcall(function()
        local name = game.Players:GetNameFromUserIdAsync(key)
      end)
      if success then
        local name = game.Players:GetNameFromUserIdAsync(key)
        local newText = gui.Frame.Bottom.ScrollingFrame.Template:Clone()
        newText.Text = key..":"..name
        newText.Visible = true
        newText.Parent = gui.Frame.Bottom.ScrollingFrame
        wait(0.05)
      else
        print(key)
        err("Uknown user " .. v["key"])
      end
   end
 end

The error is at

err("Uknown user " .. v["key"])

It printed properly and stuff but on that part it errors attempt to call a string value.
Does anyone know why?

2 Likes

err isn’t a function. It returns the error message for your pcall.

2 Likes

Err is a variable. So IDK what your doing with it in your code heh.

Instead do this:

else
     print("Unknown user .. " " .. v["key"])
1 Like

err It’s not a function, instead, you could use:

warn(err)

or what @ComplicatedParadigm said,

@ComplicatedParadigm @ItzMeZeus_IGotHacked

Ah sorry I found the problem, I had a err function and forget that I defined the error as err too.

1 Like

Can you show me the err function please?

local function err(errText)
				local gui = script.Guis.ErrGui:Clone()
				gui.ErrText.Text = "Error: "..errText.."."
				gui.Parent = player.PlayerGui
				game:GetService("TweenService"):Create(player.PlayerGui.ErrGui.ErrText, TweenInfo.new(1), {TextTransparency = 0}):Play()
				game:GetService("TweenService"):Create(player.PlayerGui.ErrGui.ErrText, TweenInfo.new(1), {BackgroundTransparency = 0.5}):Play()
				wait(4)
				game:GetService("TweenService"):Create(player.PlayerGui.ErrGui.ErrText, TweenInfo.new(1), {TextTransparency = 1}):Play()
				game:GetService("TweenService"):Create(player.PlayerGui.ErrGui.ErrText, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
				wait(1)
				gui:Destroy()
			end

You should to re-name that function, the script is calling the err value of the pcall instead of the function you made before.

1 Like

I instead changed the pcall err to errs because I used the function in many more and it would be a hassle to change all of them.

1 Like