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 bypass lower/upper case for TextBox.Text:match() ?

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

✓ Accepted answer

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()

1 comment

0

Thank you!

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