Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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?

0
String manipulation Arkrei 389 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
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

Ad

Answer this question