Is there any way to get the Player's first username?

I am making a game where an NPC calls you by your first ever username (the username you first used to join roblox). I have spent a while going through the forum and I have seen nothing. Is there is any other way to get the player’s first username?

If not, I may just have to make the NPC call the user by their current username.

7 Likes

You need to use proxies to obtain the information from the Roblox user API (scroll down to username history)

2 Likes

How may I go around doing that? I have never dealt with proxies before.

2 Likes

Well, you either have to create your own proxy (better for security) or use an existing one (like roproxy). Then do HttpService:GetAsync(PROXY_URL) o retrieve the info

1 Like

Where may I get the Proxy URL? :slightly_smiling_face:

1 Like

This should work:

local HttpService = game:GetService("HttpService")
local UserId = PLAYER_USERID

local UsernameHistory = HttpService:JSONDecode(HttpService:GetAsync(`https://users.roproxy.com/v1/users/{UserId}/username-history`))

local previousUsernames = UserNameHistory.data

if #previousUsernames == 0 then
    warn("Player has no previous usernames")
end

for _, previousUsername in previousUsernames do
    print(previousUsername)
end

local firstUsername = previousUsernames[1].name
4 Likes

Alright, I’ll try it later to see if it works. Thanks :+1:

1 Like

Updated the script btw. Also make sure HTTP requests are enabled

1 Like

Does it have to be in a server script or a local script?

1 Like

Server script, you can communicate with the client through RE

2 Likes

For some reason, I tried it out and it just kept on returning nil

(and also I was trying to set the value of a string value to the first username if the player is the only person in the server)

1 Like

Code?

game.ReplicatedStorage.Events.UserIDSent.OnServerEvent:Connect(function(plr)
local HttpService = game:GetService("HttpService")
local UserId = plr.UserId

local UsernameHistory = HttpService:JSONDecode(HttpService:GetAsync(`https://users.roproxy.com/v1/users/{UserId}/username-history`))

local previousUsernames = UsernameHistory.data

if #previousUsernames == 0 then
	warn("Player has no previous usernames")
end

for _, previousUsername in previousUsernames do
	print(previousUsername)
end

	local firstUsername = previousUsernames[1].Name
	script.Parent.Value = firstUsername
	end)
1 Like

Name should be lowercase like this name

2 Likes

Oh, I thought it was a mistake so I decided to correct. Thank you. :slightly_smiling_face:

1 Like

Just tried and it worked. Thank you! :slightly_smiling_face: :+1:

2 Likes

Np

2 Likes

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