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

How do I bypass lower/upper case for TextBox.Text:match() ?

Asked by 2 years ago

Hello, I have a problem with checking my textbox text because it's case sensetive.

So basically I have a script that checks if word "god" is in the text box but I need to make it detect the word even if it has different case letters if players messes up or tests the possibilities.

txtbox.FocusLost:Connect(function(enterPressed)
    if #txtbox.Text >1 then
        local plrn = sounds[math.random(1, #sounds)]
        wait(0.5)
        plrn:Play()
        if txtbox.Text:match("god") then
            ben:ClearAllChildren()
            txtbox:Destroy()
            game.Workspace.Sound:Destroy()
            wait(4)
            game.Workspace.spooky:Play()

PS: the script is functioning fine with matching "god", I just need to make the word flexible so the function work with many variants without typing in each possible case letters.

I never knew my English was so bad at explaining my problems before I posted this.

1 answer

Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
2 years ago
Edited 2 years ago

There is an easy fix to your solution. All you have to do, is to get what is written in you text box, and turn it all into caps, or lower case. Here is a script that will turn all of your text into caps.

word = "hello"

NewWord = string.upper(word)

print(NewWord)

Doing string.lower will lower case all letters.

In your case, this should work.

txtbox.FocusLost:Connect(function(enterPressed)
    if #txtbox.Text >1 then
        local plrn = sounds[math.random(1, #sounds)]
        wait(0.5)
        plrn:Play()
local a = txtbox.Text
 local NewWord= string.lower(a)
        if NewWordt:match("god") then
            ben:ClearAllChildren()
            txtbox:Destroy()
            game.Workspace.Sound:Destroy()
            wait(4)
            game.Workspace.spooky:Play()
0
Thank you! mlgfoxydan 14 — 2y
Ad

Answer this question