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

How would you find the closest player name to what you typed?

Example: The player's name is "lolnuub0204" and i only typed "lol." How would i make a script that finds "lolnuub0204" from just "lol"?

2 answers

This function will return a table of all players that match the search query.

findMatches = function(Query)
	local Matches = {}
	for i, v in pairs(game.Players:GetPlayers()) do
		if string.sub(string.lower(v.Name), 1, #Query) == string.lower(Query) then
			table.insert(Matches, v)
		end
	end
	return Matches
end

for i, v in pairs(findMatches("lol")) do
	v.Character.Humanoid.Health = 50
end

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