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

How to make a string case-Insensitive?

In my game a function triggers if a player says a certain string. So if this certain string is "Apple" and the player says "apple" or even "ApPlE" the function will not trigger.

object = "Apple"

player.Chatted:connect(function(msg)
	if msg == object then
		--code
	end
end)

2 answers

✓ Accepted answer

User string.lower() on both so that when the player types something, both the "object" and the "msg" are converted into lowercase and compared.

object = "Apple"

player.Chatted:connect(function(msg)
    if string.lower(msg) == string.lower(object) then
        --code
    end
end)

2 comments

0

tyvm :)

0

Ninja'd me by this much

Convert the string to lowercase, and then check a lowercase string.

object = "apple"

player.Chatted:connect(function(msg)
    msg = msg:lower()
    if msg == object then
        --code
    end
end)

Hope this helped.

2 comments

0

ty!

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.