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

How do I use string.lower?

I think I want to be using 'string.lower' anyway...

I want the player to type someone's name into a TextBox, then for them to press a TextButton and then for the game to find the player who's name has been typed in.

I currently use

local plr = game.Players:FindFirstChild(script.Parent.Parent.TextBox.Text)
if plr == nil then
	print("plr == nil")
else
	print("where everything else goes")

But using it in the above method makes it caps sensitive. I do not want it to be caps sensitive.

How would I do this?

Thanks,

  • Sam4550

3 answers

Well if your using a textbox i can help! :)

script.Parent.MouseButton1Click:connect(function() --Guessing you click a button to look for the player.
for i,v in pairs(game.Players:GetPlayers()) do --Gets all the players in game.
if v.Name:lower():find(script.Parent.Parent.TextBox.Text or v.Name:lower() == script.Parent.Parent.TextBox.Text then --Checks to see if the player is like or is the TextBox's text.
print("Player found")
else
print("Player not found")
end
end
end)

There are two very simple ways.

local string = "HI EVERYONE"

print(string.lower(string))
print(string:lower())

As you can see, string.lower() makes the given string lower case, and :lower() does the same thing, it's just in method form.

Sticking with the code provided, it would be.

local plr = string.lower(script.Parent.Parent.TextBox.Text)
if not game.Players:findFirstChild(plr) then
	print(plr .. " Is Nil") -- My Personal Preference, it will print what the string was AND say it was nil.
else
	print("where everything else goes")

Also, i couldent help but notice you used 4 spaces for the indentions. Do you know Python?

1 comment

0

You paid attention to the amount of spaces?

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