Find Argument in String

Hello. I have a script that gets fired on a chat message, and I want it to find a custom 2-word argument when a command is fired. The alias for the command to get triggered is “hey siri,”.


1. Simple Code Context
-- Command Name
spawnmap = {
	"spawn (MAP)" 
-- made so multiple aliases can be within one command, 
-- however the solution does not need to include this
}
-- Imagine the chat when a player sends a message:
[PLAYER]: hey siri, spawn Default Map

2. Checking Player Message

With my chat script I need to be able to check if the player uses the command like so

if CheckPlayerMessage(msg, spawnmap, user) then
     local success, map = FindArgumentInPlayerMessage(msg, spawnmap, user)
     -- after this ill check if the map string matches a map. This is unimportant
end
3. This is where I need help

Lastly we have an unfinished function which I need help making. This is basically the main part of this question.

function FindArgument(msg, Type)
	if string.find(Type[1], "(MAP)") then
		
	else
		return false
	end
end

This is all in the same script. The list shown in the first step is defined in the other steps, including the msg and user argument in the two functions.

Thanks in Advance! - Dev_Mathe

Best answer will be marked as a solution, no matter the quality. I’ve been having trouble with this for quite a while now.

Maybe this?

string.split(str, “ “)[1]

I’ll try. Thank you for your answer though :slight_smile: