Admin Script help needed

I am trying to create an admin script but i keep getting the same error

Error - invalid argument #1 to ‘pairs’ (table expected, got nil)

                    Code
                   \/\/\/

print("TP Function fired by"..sender.Name)
for i, playerName in pairs(arguments) do
	print(playerName)
end

Any help will be great.

I am not certain, but I believe the error is caused by an issue with the table called, arguments.
It looks like the table called, arguments is nil, which causes the loop to output an error.

The arguments variable is nil when the loop is being created.

Make sure that you’re arguments variable is an array/table of some sort.

1 Like

do you know how to fix this. I know its with the table

It is as the error states: arguments is nil at the time when the loop is used.

Make sure you set the variable *before` the loop is executed to prevent issues.

1 Like

Mind sending the whole script?
As everyone said the table argument is nil.

if the full code is this;

print("TP Function fired by"..sender.Name)
for i, playerName in pairs(arguments) do
	print(playerName)
end

that is definitely not going to work.

you need to have a player.Chatted event being listened to, and from that event handle the TP command.

Spoonfeeding
player.Chatted:Connect(function(msg)
    arguments = msg.split(" ")
    if string.lower(arguments[1]) == "tp" then
        table.remove(arguments,1)
        for i, playername in pairs(string.split(arguments[1],",")) do
            print(playername)
        end
    end
end)