Hi there!
For context, I’m using :GetNameFromUserIdAsync() in unison with a global data store to retrieve players’ names based on their ID, with the key of the data being their ID.
I ran into an issue that required me to begin using pcall (as I should have done from the beginning) on the Async call. After switching to using pcall, my code has broken completely.
But I don’t think this is a simple bug with my code. I’ve ran over the code multiple times and added some prints for debugging. After doing so, I made some strange discoveries.
I’ve ensured the keys for my Datastore values are fine with prints, they are the proper user IDs. Using the command line and running :GetUserFromUserIdAsync() returns the username with no problems. HOWEVER, even when the pcall is successful, it’s returning nil. I did some deeper digging and realized the following:
When the pcall is NOT successful, I get the following error message:
false Players:GetUserIdFromNameAsync() failed: Unknown user -1
Okay, I can understand this error. It’s the reason I had to use pcall in the first place, as there are players in the datastore from studio test sessions with IDs <1.
HOWEVER, what does NOT make sense, and I believe what is causing the successful pcalls to return nil, is that it says I’m calling GetUserIdFromNameAsync
- and I am not. I’ve checked, double checked and triple checked to ensure my code is indeed GetNameFromUserIdAsync and it is, as shown below:
local success, plrName = pcall(function()
Players:GetNameFromUserIdAsync(data.key)
end)
So why on earth is it returning nil even when successful, and why does it think I’m calling GetUserIdFromNameAsync (when I evidently am not)
Is this a studio bug? Have I done something wrong?