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

How Can I Check Text Without Specific Caps?

Asked by 4 years ago

How can I make it so then this would not need to be specific caps?

if script.Parent.Text == "Hi" then -- Text Doesn't Need Specific Capitalization.

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

You can use string.match.

if string.match(script.Parent.Text, "[%l]+") == "hi" then -- changed "Hi" to "hi"

I used string.match to lowercase all the letters in "script.Parent.Text".

For more info, go to this page:

https://developer.roblox.com/en-us/articles/string-patterns-reference

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Make sure to convert both ends to lowercase or uppercase so that the equals check would always be right:

if script.Parent.Text:lower() == "hi" then

You can run this example to see it in action:

local values = {"HI", "Hi", "hI", "hi"}
for i,v in ipairs(values) do
    print(v:lower() == "hi")
end
0
Sorry it's just that this one is more lines. Aiden_12114 79 — 4y

Answer this question