How can I make tables not cap sensitive?

So, I’m trying to make a game similar to Word Bomb but with categories. However, the textbox will accept “English” but not “english.” So, i was wondering if you can make it so it won’t be caps-sensitive without having to type the lowercase in the categorized table.

(My table that goes on…)
image

(DOES NOT WORK)

(WORKS)

--Here is the LocalScript I'm handling the player input by:

categoryEvent.OnClientEvent:Connect(function(Category)
	local TextboxClone = Textbox:Clone()
	TextboxClone.Parent = Frame
	Frame.Visible = true
	TextboxClone.Visible = true
	
	TextboxClone.FocusLost:Connect(function()
		--print("FOCUS LOST")
		for i, v in categories do
			if i == tostring(Category) then
				--print("Category Found")
				for name, item in v do
					--print(item)
					if tostring(item) == TextboxClone.Text then
						success = true
						print("Success!")
						TextboxClone:Destroy()
						Frame.Visible = false
						task.wait(1)
					end
				end
			end
		end
	end)
end)


To fix this you can make use of string.lower(), or string.upper(). It’s a function that will return the same string that you plug in, except with all letter lowercase or uppercase, depending on which one you use.

I believe the script should work if you change:
if tostring(item) == TextboxClone.Text then
To:
if string.lower(tostring(item)) == string.lower(TextboxClone.Text) then

Thank you. Will this also work for upper-case like this?

else
						if string.upper(tostring(item)) == string.upper(TextboxClone.Text) then
							success = true
							print("Success!")
							CAEvent:FireServer() -- Fires so it's the next player's turn
							TextboxClone:Destroy()
							Frame.Visible = false
							task.wait(1)
						end
					end

Upper-case will also work fine. I’m happy to help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.