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

Using FindFirstChild without upper and lower case?

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

✓ Accepted answer

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

2 comments

0

Okay, im just doing it case-sensitive. Thank you!

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.

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