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 5 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 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
1game.Players.PlayerAdded:Connect(function(player)
2    player.Chatted:Connect(function(message)
3        if message:match("/kill") then
4            print( string.sub( message , 6 ) )
5            --[[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]]--
6        end
7    end)
8end)

if you don't really understand string.sub then go here https://developer.roblox.com/api-reference/lua-docs/string

Ad

Answer this question