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

Using FindFirstChild without upper and lower case?

Asked by
OKRPLAY 25
6 years ago

Hi!

Im currently making a room giver for a hotel of a friend. The receptionist will then type "giveroom PLAYERNAME" in the chat. This is a part of my script:

local plrtogive = msg:sub(10)
if game.Players:FindFirstChild(plrtogive) then
    print("Opening give GUI for " .. plrtogive)
end

The problem is: when i type "giveroom OKRPLAY" in the chat everything works fine. When i type "giveroom okrplay", it dosent find it.

It is possible to use FindFirstChild without upper and lower case?

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
6 years ago

Technically no, but you can get around this by comparing all Players' names in lowercase (or uppercase, but lower is more common) instead of directly looking for one:

local playerToGive = msg:sub(10):lower()
for _, player in pairs(game.Players:GetPlayers()) do
    if player.Name:lower() == playerToGive then
        print("Opening give GUI for " .. player.Name)
        break
    end
end
0
Okay, im just doing it case-sensitive. Thank you! OKRPLAY 25 — 6y
1
Is there a reason you can't use this loop? It's a few more lines of code but it solves the problem without any scope bloat. adark 5487 — 6y
Ad

Answer this question