Getting a "Custom Name" ( rather than Player.DisplayName )

I’m gonna answer these prescribed questions:

  1. What do you want to achieve?
    I want to make it easier to target players with chat commands.

In a chat cmd system that I’ve already scripted, I want to let a PrivateServerOwner use any Customized Names they (might) have already set for friends who are playing with them.

  1. What is the issue?

Screenshot where one can set a very simple Custom Name for friends who have not set a Display Name over their complicated UserName.

  1. What solutions have you tried so far?
    A reasonable amount (hopefully) of searching.

Howdy all,
I’m a rookie game dev. This is my first question post

I’ve scripted a chat cmd system along with extra admin features/private server privileges etc. and I know that I can get Player.DisplayName for functions. But of course, that’s often, by default, a player’s typewriter-unfriendly UserName if they haven’t yet set a Display Name.

This “Customize Name” feature on the Client is very useful in game play and the social media platform part of Roblox. Friends who frequently change their DisplayName can be hard to quickly recognize. I recently started using it to find peeps in my own friends list when gaming, so now I wonder how a Customized Name could be used in a chat command system.

In other words, in absence of a suggestive auto-fill feature (which would be a scripting hurdle I don’t want to jump over at the moment) I would like to let an Admin-powered player use all their Custom Names (that they have already set for friends or whoever is on their private server with them at a given time) in my chat command system.

I still need to get my code to properly deal with two players on the same server with identical DisplayNames, and I think this Custom Name feature on the Client would be really convenient for admin command use (at least, in the chat).

I suspect that the “not visible to other players” might imply that a Customized Name also isn’t visible to a developer’s scripts? Sorry if this topic is answered somewhere else. I searched but couldn’t find anything definitive on this. Found nothing in documentation, but maybe I missed something somewhere. Most results give me info about Display Name issues/questions.

What I really should do is make a GUI (I’m just reluctant to further clutter the screen) and I likely will do so eventually. At the moment I have most admin command functions working by way of chat only. It would be great to make that easier for private server owners.

/Thanks in advance ramble: I did at least a year of lurking/reading prior to getting an account almost a year ago and until today suspected I might not ever need to write my own question, as the community here tends to be so friendly, resourceful and helpful (and my specific problems are commonly fixed in somewhat related solutions) This old dog has learned new tricks thanks to countless super clever coders (many who are a fraction of my age) It’s hard to imagine a better community of people in tech

1 Like

What do you mean by target? I don’t understand, please specify.

Thanks for the question :slight_smile:
I have it where a whitelisted player (like a private server owner) has commands they can execute in the chat. Some of the commands can make the Admin player faster or a better jumper, or fast travel/teleport somewhere. But some commands do things to other, specified, players.

For example, teleporting a friend to another friend. These friends have complicated UserNames (see below) and are also by default, their unedited DisplayNames

Instead of typing in chat:

/teleport Mxyzptlk743009 to ZG0391Brzęczyszczykiewicz

Type in chat

/teleport Mike3 to Greg

And because the Admin player has previously, in his own Client app, set a Custom Name (Mike3) for his friend “Mxyzptlk743009” and he has already set “Greg” as a Customized Name for his other friend (ZG0391Brzęczyszczykiewicz), his friends undergo teleportation as expected.

The alternative would be for the Admin player to ask his friends to go into their Roblox account settings and change their DisplayNames to something simple, so that the chat command system could use their simplified names for teleporting them around the game.

My admin command scripts can handle chat invocations that use DisplayNames as an option to UserName, but that is of no advantage if a player with a complicated UserName hasn’t set a DisplayName for themselves.

They you may wanna do when processing command,
check if the following username is in a Custom Name list of admin, then if it does, then simply use that player that that username refers to.

Well, that is what I am asking. How do I find that list you mentioned?

I don’t know the syntax for getting a Custom Name that somebody has set for one of their friends. I know how to get a UserName and UserID and DisplayName and PrivateServerOwnerID for example, but I don’t know how to get this Custom Name in the screenshot I posted.

I cannot find documentation for that “Customize Name” feature on the client.
How can a script get any Custom Name that a client has specified for his friends? Please tell me where /what service /list has this data. I’m at a total loss. Can’t find info on “Customize Name” in the docs. I suspect it is currently impossible

I dont think so it is possible, it is private info tho

1 Like

It is not possible, that info can only be accessed by RobloxScriptSecurity level scripts, aka CoreScripts. You might want to use their display names instead.

2 Likes

You could do something like this for a program … could even create a database. But outside that one program I’m not sure this could be done.

local Players = game:GetService("Players")

local customNames = {
    ["Mike"] = "Mxyzptlk743009",
    ["Dave"] = "ZG0391Brzęczyszczykiewicz"
}

local function getPlayerByCustomName(customName)
    local username = customNames[customName]
    if username then
        return Players:FindFirstChild(username)
    end
    return nil
end

local function onPlayerChatted(player, message)
    local action, customName = string.match(message, "^/(%w+) (%w+)$")
    if action and customName then
        local targetPlayer = getPlayerByCustomName(customName)
        if targetPlayer then
            if action == "greet" then
                player:SendMessage("Hello, " .. targetPlayer.Name .. "!")
            end
        end
    end
end

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message) onPlayerChatted(player, message) end)
end)

for _, player in ipairs(Players:GetPlayers()) do
    player.Chatted:Connect(function(message) onPlayerChatted(player, message) end)
end

Pretty simple script here, just a name table …

On second thought: I guess you could make your own custom module and drop it in all your created games …

local CustomNames = {}

CustomNames.Mappings = {
    ["Mike"] = "Mxyzptlk743009",
    ["Dave"] = "ZG0391Brzęczyszczykiewicz"
}

function CustomNames.GetPlayer(customName)
    local username = CustomNames.Mappings[customName]
    if username then
        return game.Players:FindFirstChild(username)
    end
    return nil
end

return CustomNames

This would be more something for you only however.

1 Like

Yeah, DisplayNames are too often lacking, and like you said about your suggestion - it would be something too exclusive. I need a solution for all admins /group members /private server owners. I need a temporary game-time only table that’ll be different on each active server.

U got me thinkin’ tho.
I could put something in StarterGui for PlayerAdded that compels them to input a short nickname before beginning the game. I suppose I could make a Nickname field in leaderstats and list the plr entered nickname there alongside coin/trinket totals. I could then allow those temporary short’n’simple names to be used in chat commands. I could even allow the Admins to edit any nickname I suppose, though that’s almost getting out of hand for my current coding chops … maybe putting together a suggestion/auto-complete would be less trouble.

Perhaps I should just get on with making menu Guis for all commands. It’d certainly be easy to click on a long name in a list rather than typing it.

Thanks to all who responded

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.