Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i detect text that gets put after a specific part of a chat message?

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?

1 comment

0

String manipulation

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.