Here's my script:
Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
-- Check for admin here.
if(msg:sub(1,1)=="/")then
local command, arg1, arg2 = msg:match("^%/(%S+)%s+(%a+)%s(.+)$")
print(command)
print(arg1)
print(arg2)
end
end)
end)
Everything's fine, I define the service Players elsewhere but if I added it this would be a standalone script.
The area of problem is here:
local command, arg1, arg2 = msg:match("^(%S+)%s+(%a+)%s(.+)$")
And it works like I want it to. Examples:
"/displayMessage all Hey guys!"
print(command) -- displayMessage
print(arg1) -- all
print(arg2) -- Hey guys!
However some commands will only require two arguments, but then everything's nil.
"/kill me"
print(command) -- nil
print(arg1) -- nil
print(arg2) -- nil
How could I fix this?
This code is mostly from one of my past questions.
I modified Blue's solution a little to fit my new situation here, but I'm still really bad with string manipulation. :c
Thanks for any help!

2 comments
<3
:3