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 find a player if I have his name with lowercase letters?

So I'm making a command bar, and for example, I have a kill command. The commands are seen from the textbutton.

My name is Player, and I have this text in the textbutton: kill player

What I want to do: -Check if there is a name "Player" in the game (with the text being 'player', not 'Player') -Kill the player if there is

What I've tried:

local textbox = script.Parent
local textbutton = script.Parent.ExecuteButton

local FindPlayer = function(plr)
	local newplrs = game:GetService('Players'):GetPlayers()
	for _,n in pairs(newplrs) do
		if (string.lower(plr) == string.lower(n)) then
			return true
		end
	end
end

Kill = function(text)
	if (string.sub(text,1,5) == 'kill ') then
		local trgPlayer	= FindPlayer(string.sub(text,6))
		if trgPlayer and trgPlayer.Character then
			trgPlayer.Character:BreakJoints()
		end
	end
end

textbutton.MouseButton1Down:connect(function()
	Kill()
end)

Any help would be appreciated.

2 comments

0

This code looks fine, except for the fact that you never give your Kill function an argument when you call it.

0

The code from 22-24 was just an example I made up in a few seconds, the actual code is way more complicated.

1 answer

With the player's name, use

string.lower()

on it, then when testing if the player is in game.Players use

string.lower()

on the objects in game.Players as well.

3 comments

0

Does it work?

0

Yes, it worked, just can't upvote.

0

You should be able to...

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