So basically when the person types in a user's name into the GUI it will hand them that specific item. Right now, the capitalization has to be the same capitalization as the person's username, for example, if the player's name was 'Player1', you have to type 'Player1', not 'player1' or 'PlaYer1' etc. How would I edit this so you can use any capitalization in the name?

Here is the script which is in my hand to button:

local eventStorage = game:GetService("ReplicatedStorage")

script.Parent.MouseButton1Click:connect(function()
	local target = script.Parent.Parent.TargetPlayer.Text
	eventStorage.HandTo:FireServer(target)
	script.Parent.Text = "Done!"
	wait(2)
	script.Parent.Text = "Give"
	script.Parent.Parent.TargetPlayer.Text = ""
end)

Here is the script for giving the player the item:

local GroupID = 0

local MinRank = 0

local rs = game:GetService("ReplicatedStorage")

local handToEvent = Instance.new("RemoteEvent", rs)
handToEvent.Name = "HandTo"

rs.HandTo.OnServerEvent:connect(function(requester, target)
	for _,child in ipairs(requester.Character:GetChildren()) do
		if child:IsA("Tool") then
			child.Parent = game.Players[target].Backpack
		end
	end
end)

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function()
		if player:GetRankInGroup(GroupID) >= MinRank then
			script["Hand To"]:Clone().Parent = player.PlayerGui
		end
	end)
end)

Thanks, TypicallyPacific

11 comments

0

local name = "PLAyer1" if name:lower() == "player1" then print("Use string.lower") >> Use string.lower. You can use :lower() or :upper() on strings to transform every character of said string to one specific case.

0

Would this work for any name entered into the GUI?

0

Also, if I were to transform the case to all upper or all lower then the code wouldn't work as they need the exact capitalization to find a player in players.

0

What..? Just read the documentation of string.upper and string.lower.

0

you can compare it to the upper case or lower case of player in players

0

I did, it will turn the string into all uppercase or all lowercase. If I were to do this, how would the script be able to find the player in the players service? It needs the exact capitalization as the player's name.

0

So run string.lower() on the player's name and the player you are searching for and compare them. This is how this is done in Lua.

0

And how would I do that exactly?

0

if typedDownName:lower() == playersActualName:lower() then --this is what i mean, both lower case

0

So would I just put that in my code? "if typedDownName:lower() == playersActualName:lower()"

0

no that was just an example, you could do | for _, player in pairs(game.Players:GetPlayers()) do if player.Name:lower() == target:lower() then child.Parent = game.Players[player.Name].Backpack end end | on line 13 in your server script