Specific TextBox argument

Hi there :slight_smile:
How would I be able to grab, for example, only the second or third word from a TextBox input? I’m pretty sure people were trying to do this before, so I spent some time looking through the Developer Hub and the Forums but couldn’t find any solutions to my question unfortunately.

Example input:

/search info PLAYER_NAME

I now want to grab the player name argument to work with it in a script.

you need to use a string.gmatch loop

local count = 0
for string in string.gmatch(string,[^%s]+) do
count = count + 1
if count == 2 then
print(“this is the 2nd word”)

basically, look into strings and string patterns

1 Like
local text = script.Parent.Text -- /search info playername
local arguments = text:split(" ")
for i,v in pairs(arguments) do
    print("Argument "..i..": "..v)

will output

Argument 1: /search
Argument 2: info
Argument 3: playername

Not tested