I am trying to make a script that fires when a person chats the word 'test'. However, there are multiple ways to say test in ROBLOX. You can say "TEST", "TesT", "teSt" and much more. How do I make it so that it fires for all of those no matter how it is capitalized?
✓ ANSWER ACCEPTED
how do I allow a function to fire no matter how the word in the chatted event is capitalized?
2 answers
✓ Accepted answer
Use string.lower(), here are some usage examples. https://www.robloxdev.com/articles/Lua-Libraries/string#string.lower
X = "HAHA" -- we have "X", a capitalized variable defined as HAHA,
if string.lower(X) == "haha" then -- if X uncapitalized is "haha", then
print("Yes!")
end
So, you would basically do
if string.lower(msg) == "blahblah" then
end
2 comments
0
You can also do (msg):lower() if you want, but that's generally harder for beginners
0
All you need to do is acknowledge that the first argument being sent is whatever is before the colon
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Msg)
if (Msg:lower() == "haha") then -- this will lower the message and how it's capitalized.
end
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
String manipulation, im not good at it though..... It would be something like if string.lower and string.Higher <-- idek then run.... idek, Im terrible at string manipulation
Compare using string.lower.
Use string.lower, left you an answer, might be undetailed because 27starghost and i were racing for it
@greatneil it's string.upper xD
im decent with string manipulation since i used to try to make parsers and stuff back in the day
oh ;-;, Told you I sucked at string manipulation