maccchh
(mach)
March 15, 2024, 11:56pm
#1
Im making a custom command system, which also includes a announcement command.
In of it the command can be triggered in any spot even after a couple of messages
heyyy :announce yo!
input: “yo!”
but i would like to know how to get all the words that come after
heyyy :announce yo, hi guy!
input: “yo, hi guy!”
1 Like
Doomcolp3
(Doomcolp3)
March 16, 2024, 12:36am
#2
you can basically do this with string patterns!
local Pattern = ":command%s.+"
local Result
Player.Chatted:Connect(function(msg)
if msg:match(Pattern) then
Result = string.gsub(msg, ":command%s", "")
end
end)
What is this pattern matching?
:command%s%w
“:command” is obviously matching “:command”
%s matches a white space
or a space
And .+ matches all letters after the space
Should work but I can’t test rn
If you’d like to tweak it, learn more about string patterns here:
What are String Patterns?
String patterns, is a specific arrangement or sequence of characters within a text or a string. For example, if you’re looking for all the numbers in a set of strings, you can create a string pattern that captures only the numbers in each string, (e.g “helloworld123”, pattern: “%d+”).
The Usage of String Patterns
Search and Identify: You can create patterns to search for specific text within strings. For instance, you could use a string pattern to find all player n…
3 Likes
Doomcolp3
(Doomcolp3)
March 16, 2024, 12:40am
#3
And I am aware I could use sub patterns instead of string.gsub
but I’m too lazy to do it unless you really want me to do it
1 Like
maccchh
(mach)
March 16, 2024, 12:42am
#4
Doomcolp3:
%s.+
Doesn’t really matter as your 1st post was a solution. thanks mate
1 Like
system
(system)
Closed
March 30, 2024, 12:43am
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.