How can I refer to more than one object in a table?

Hi, I’m trying to make admin commands, but I want to refer to more than one argument in a table when said admin says something like ‘give’ or ‘kick’. Refer to the following images:

Commands will be revealed in the next image; cmdName is the name of the command being used; plr is player; splitstring is the players message split (divided by spaces)

Commands is a variable (local commands = {}); findPlayer(plr) is a function that finds the player in game:GetService("Players"):GetPlayers().

There is no error in anything, as other commands are working as well; the only thing I want to know is how to refer to multiple arguments in a table.

--want to give more than just 2

What’s wrong with local arg3 = arguments[3]?

This isn’t the solution, see above post for answer.

But why do this

When you can do

local arguments = table.clone(splitstring)


local arguments = {select(2,table.unpack(splitstring))}

(Also please paste the code into code block next time instead of pasting screenshot)

1 Like

it could be an infinite amount of words ( not seriously )

I assume you wanna try to refer n amount of arguments in a function depending on what type of command you are using. In that case, you can check out variadic functions.

1 Like