Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

6 comments

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

0

Compare using string.lower.

0

Use string.lower, left you an answer, might be undetailed because 27starghost and i were racing for it

0

@greatneil it's string.upper xD

0

im decent with string manipulation since i used to try to make parsers and stuff back in the day

0

oh ;-;, Told you I sucked at string manipulation

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.