How do I input "me" instead of my username for Players (CMDR)

What I want to accomplish:

So basically, I use CMDR for my admin panel needs and I was wanting to make it so when I type in player names, I don’t have to input my whole roblox username and I could just input me. However I don’t know how I could accomplish that and how to script that in. Here are the scripts I want to rewrite to accomplish that:

Players Module Script:

local Util = require(script.Parent.Parent.Shared.Util)
local Players = game:GetService("Players")

local playerType = {
	Transform = function (text)
		local findPlayer = Util.MakeFuzzyFinder(Players:GetPlayers())

		return findPlayer(text)
	end;

	Validate = function (players)
		return #players > 0, "No player with that name could be found."
	end;

	Autocomplete = function (players)
		return Util.GetNames(players)
	end;

	Parse = function (players)
		return players[1]
	end;

	Default = function(player)
		return player.Name
	end;
}

return function (cmdr)
	cmdr:RegisterType("player", playerType)
	cmdr:RegisterType("players", Util.MakeListableType(playerType))
end

The “Util” function:

function Util.MakeFuzzyFinder(setOrContainer)
	local names
	local instances = {}

	if typeof(setOrContainer) == "Enum" then
		setOrContainer = setOrContainer:GetEnumItems()
	end

	if typeof(setOrContainer) == "Instance" then
		names, instances = transformInstanceSet(setOrContainer:GetChildren())
	elseif typeof(setOrContainer) == "table" then
		if
			typeof(setOrContainer[1]) == "Instance" or typeof(setOrContainer[1]) == "Enum" or
				(typeof(setOrContainer[1]) == "table" and typeof(setOrContainer[1].Name) == "string")
		 then
			names, instances = transformInstanceSet(setOrContainer)
		elseif type(setOrContainer[1]) == "string" then
			names = setOrContainer
		elseif setOrContainer[1] ~= nil then
			error("MakeFuzzyFinder only accepts tables of instances or strings.")
		else
			names = {}
		end
	else
		error("MakeFuzzyFinder only accepts a table, Enum, or Instance.")
	end

	-- Searches the set (checking exact matches first)
	return function(text, returnFirst)
		local results = {}

		for i, name in pairs(names) do
			local value = instances and instances[i] or name

			-- Continue on checking for non-exact matches...
			-- Still need to loop through everything, even on returnFirst, because possibility of an exact match.
			if name:lower() == text:lower() then
				if returnFirst then
					return value
				else
					table.insert(results, 1, value)
				end
			elseif name:lower():sub(1, #text) == text:lower() then
				results[#results + 1] = value
			end
		end

		if returnFirst then
			return results[1]
		end

		return results
	end
end

--- Takes an array of instances and returns an array of those instances' names.
function Util.GetNames(instances)
	local names = {}

	for i = 1, #instances do
		names[i] = instances[i].Name or tostring(instances[i])
	end

	return names
end

local selfUsername = "yourusernamehere"

local player
if argument:lower() == "me" then player = sender/game.Players.LocalPlayer else player = game.Players[argument] end

I don’t want to do it that way. I want it to check the player who’s using it’s username and will allow you to input me for any player not just one set player.

players = game:GetService("Players")
player = players.LocalPlayer
playerName = player.Name

This doesn’t work with either script even if I attempt to rewrite it.

This still isn’t technically what I am asking for. I want to make it to parse through the command that is sent and detects “me” as the player running the command.

You could use a RemoteEvent:FireServer function which when called fires a RemoteEvent.OnServerEvent event to achieve this.

You could try

local name = game.Players:GetNameFromUserIdAsync(game.CreatorId)

Of course, it doesn’t work if you aren’t the creator. You can also try

_G.me = "Stickpuppet"

Hope it helped!

3 Likes

I think they mean “me” as in like an admin command: :fly me
Not themselves. Like every person who runs this, me is theirselves.