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

how do I allow a function to fire no matter how the word in the chatted event is capitalized?

Asked by
zValerian 108
6 years ago

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?

0
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 greatneil80 2647 — 6y
0
Compare using string.lower. SummerEquinox 643 — 6y
0
Use string.lower, left you an answer, might be undetailed because 27starghost and i were racing for it DaCrazyDev 444 — 6y
0
@greatneil it's string.upper xD DaCrazyDev 444 — 6y
View all comments (2 more)
0
im decent with string manipulation since i used to try to make parsers and stuff back in the day DaCrazyDev 444 — 6y
0
oh ;-;, Told you I sucked at string manipulation greatneil80 2647 — 6y

2 answers

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

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
0
You can also do (msg):lower() if you want, but that's generally harder for beginners DaCrazyDev 444 — 6y
0
All you need to do is acknowledge that the first argument being sent is whatever is before the colon Vulkarin 581 — 6y
Ad
Log in to vote
0
Answered by
angeI1001 123
6 years ago
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)

Answer this question