This is for an admin script. How do I have it search for the second space? So like ``;;setHealth [Player] [newHealth]" I cant figure out how to have the script 'know' what part is the name and what part is the value that the health will be set to
String patterns are just what you need. I recommend splitting the string after the signal character(s) (in your case, the ";;") into a command and argument.
local SignalCharacters = ";;" local Message = ";;setHealth Username 100" function HandleMessage(Message) if Message:sub(1, #SignalCharacters) ~= SignalCharacters then -- Return early if message isn't a command return end local CommandSubstring = Message:sub(#SignalCharacters + 1) local Command = nil local Arguments = {} for Match in CommandSubstring:gmatch("%w+") do -- If there's not a first match yet, it's the command! if Command then table.insert(Arguments, Match) else -- If there's not a first match yet, it's the command! Command = Match end end if not Command then return end -- Continue here to check if it's a valid command, and has the valid number of arguments, et cetera. end HandleMessage(Message)