Hello. I am wanting to know how I can detect, in this case print the text that gets put after the part in the chat that i am looking for. For an example, say the chat "requirement" is /kill. How would I be able to print what gets put right after the requirement?
✓ ANSWER ACCEPTED
How can i detect text that gets put after a specific part of a chat message?
1 answer
✓ Accepted answer
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message:match("/kill") then
print( string.sub( message , 6 ) )
--[[string.sub takes 3 arguments. the first one is the string(the players message). the second argument is where you want the sub to start. and the 3rd is where the string ends]]--
end
end)
end)
if you don't really understand string.sub then go here https://developer.roblox.com/api-reference/lua-docs/string
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
String manipulation