[HELP] bad argument #1 to 'pairs' (table expected, got userdata)

When i try to run my command i get this error:

[ERROR] addons/ulx/lua/ulx/modules/sh/warnsystem.lua:6: bad argument #1 to ‘pairs’ (table expected, got userdata)

Does anyone know what i should edit to make it works? please guys! :frowning: i really need your help
function ulx.advertsystem( calling_ply, target_ply, reason )

local affected_plys = {}
for _, v in pairs(target_ply) do // loop through all players passed in the command argument
	timer.Simple(1, function()
		if IsValid(v) then
			net.Start( "AdvertsMenu" )
			net.Send( v )


local advertsystem = ulx.command( CATEGORY_NAME, “ulx advert”, ulx.advertsystem, “!advert” )
advertsystem:addParam{ type=ULib.cmds.PlayerArg }
advertsystem:addParam{ type=ULib.cmds.StringArg, hint=“reason”, ULib.cmds.takeRestOfLine }
advertsystem:defaultAccess( ULib.ACCESS_ADMIN )
advertsystem:help( “send an advert.” )

Looks like target_ply is a single player, and not a table of players.

Basically you got an entity when you were looking for a table like Author said.