Getting a players new username from old one

Hello. I have already searched quite a few forums and I can’t find what I want. I am looking for a method that lets you input a players older username, and have it return the players newest username. How could I do this?

1 Like

What do you mean exactly by old username and new username

Previous usernames, like if they changed their actual username to smth else using robux

1 Like

Players can update their usernames for 1000 robux. (Just setting the context)

Part of a datastore has the players name in it (which is kind of stupid since I switched to userids). It’s hard to explain, but it’s necessary to keep the names in.

Oh, if that’s what they mean i’m not exactually sure if its possible once its changed. But if its a username as in the one you can change what is it like 7 days then its possible.

I am working on an admin panel, and I want to be able to ban players by username input. The game can turn that username into a userid easily using a method, but I want to add in an extra detail that will autocorrect the name typed in to its latest version.

e.g. The player gets reported to me to get banned, so I ban them by putting in their username. But within that time, they have changed it to something else. This will not mess up my system at all, but I want to add in an extra touch so when I type in their old username since that’s what they were last identified as, the game will immediately correct it to their newest username.

That wouldn’t really work because once a player changes their username, their old one goes up for grabs, which means a new player could take it. The best thing to do would be to search their username in the Roblox search, it shows results based on current and past usernames.

A player’s old usernames stay in their possession.

Did some quick research, I was wrong in my last reply. You can use Players:GetUserIdFromNameAsync, as you may have been doing already. When you put old usernames into that box, it will return the UserId regardless. From there, you can use Players:GetNameFromUserIdAsync to get the updated username. When a player submits a username into your admin panel, your script can run both of these functions and use the result of the second function, optionally updating the textbox to reflect that change.

I’ve already gone through that idea, and I think there could be a much better optimal decision.

What would be more optimized? No matter what you’re going to be making calls to external sources. If you try to do something with your datastore it’d be more complex because you’d be making the same amount of calls and then indexing a table. If you want to do something through the website, you’d have to make an API call and use a proxy which is generally slower and more work. What other optimizations are you looking to make, or moreso, what about that method is unoptimal?

2 Likes

so you will want AI then? because autocorrect is AI…

There are a couple of ways you can do this, however you are limited as most of the Player functions only Apply to players who are in the Server itself.
The Closest thing you would probably get to Finding Players would be UserService which would allow you to get a Player based on their ID, which is might more efficient and faster than getting the name, as it is forever assigned to that account, here is an example:

local f = game:GetService("UserService") -- Service
local r = Random.new() -- Random.new

while task.wait(1) do
	local randomId = r:NextInteger(1, 4e9) -- random number between 1 and 4 billion
	local Data = unpack(f:GetUserInfosByUserIdsAsync{randomId}) -- unpacks Data
	print(Data) -- Array of Data
end

However it is recommended you wrap this in a pcall() to avoid errors as this is basically sending a Request, and those can error, But another thing to keep in mind, this only works with Users that Arent Banned, Any User you type in that is banned will return as nil according to the Code, if you want to get the Data like this, you can do this which works by old names and current names.

This code will get the UserId based on the Name Given, and Retrieve the Data According to the UserId if they arent Banned:

local Inserted = game.Players:GetUserIdFromNameAsync(Name) -- gets Data from Name
local Data -- so we can get our Data out from the scope
if Inserted then -- if Data found
    Data = unpack(f:GetUserInfosByUserIdsAsync{randomId}) -- UserData
end

print(Data) -- prints User Data

Autocorrect isn’t an AI, is an algorithm that corrects you, not sur show it works but it probably know the keyboard and gets what you type and if you type wrong it ‘corrects’ it

AI means Artificial Intelligence which is basically Intelligence by a Machine

AutoCorrect is an AI as it helps the Computer detect Errors in the Language, and to Correct them accordingly.

Basically a lot of things you do on a Computer, like typing this post, is handled by an AI rather than a Human.

2 Likes

Thank you for clarifying for those who don’t know!

Try searching someone’s old name with your code who has already changed their name and see if it gives you his id, since he would still be in possesion of that name

1 Like

Yeah I know, but thecnically, from my little understanding of them, autocorrect would do this:
I write hy, which is wrong
He sees that y is close to i
Changes y with i, as it makes a real word, and y is close to i
Writes hi

But it could also be an AI, but that would mean it would do some errors, which I almost never see

Who’s “He?”

1 Like

I meant the autocorrector, that s why I said ‘he’, because corrector is male (right?)