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

How do I use string.lower?

Asked by
Sam4550 42
10 years ago

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

Log in to vote
2
Answered by 10 years ago

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)
Ad
Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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.

Log in to vote
0
Answered by
iaz3 190
10 years ago

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?

0
You paid attention to the amount of spaces? Validark 1580 — 10y

Answer this question