I'm so confused why I keep getting this error!

Just last night this script worked fine saving the “Days” data, but now it does not want to work. I have no idea what happened.

[Players:GetNameFromUserId() failed because HTTP 404 (NotFound)]

local DataService = game:GetService("DataStoreService")
local DataStore = DataService:GetDataStore("Doesnotd Martterrih now")

	local days = player:WaitForChild("leaderstats"):WaitForChild("Days")

    local Days_Data

    local success, errorMessage = pcall(function()
        Days_Data = DataStore:GetAsync(player.UserId.. "days") --(key, keyword)  --you should make it a keyword, rather than a value

    if success then
        days.Value = Days_Data        
    elseif errorMessage then
        warn(errorMessage,"Error Message")

    print(player," Has Left")
    local days = player.leaderstats.Days.Value

    local success, errorMessage = pcall(function()
        DataStore:SetAsync(player.UserId.. "days", days) --(key, keyword, value)
    if success then
        print("All Saved")
        warn(errorMessage) --warn is like print, except in orange text, showing where the warning is
1 Like

Have you enabled API services?

1 Like

yes, i have api services enabled

1 Like

On which line did you call the GetNameFromUserId() function?

line 12

local success, errorMessage = pcall(function()
        Days_Data = DataStore:GetAsync(player.UserId.. "days") --(key, keyword)  --you should make it a keyword, rather than a value

For new players, data won’t load because they are new. So you have to add a default data value so an error doesn’t occur. So here is that fixed code

local success, errorMessage = pcall(function()
    Days_Data = DataStore:GetAsync(player.UserId.. "days") or (defaultData)

Hopefully this helps you. I’m new to datastores also, so this may not be the problem.

defaultData is not a function so this has nothing to do with anything

I believe this usually only happens when something isn’t enabled, are you 100% positive that api services are enabled? What happens when you use your script in another place?

His error says Players:GetNameFromUserId() failed so he tried to get an Username from a incorect UserId

1 Like

This is most-likely a Roblox bug. You can report it to Engine Bugs. Otherwise the UserId is wrong.

Can we see the actual line of code that calls that function? You do plr.UserId, but I see no line containing the :GetPlayerFromUserId() function

This is not. This is a error with his script. And, the error he gave us isn’t about this script.

Exactly, i don’t even know where that error is!

Also it is GetNameFromUserIdAsync()

GetNameFromUserId is an internal function i’m pretty sure. GetNameFromUserIdAsync is the method that is exposed

1 Like

It isn’t. You can use it in every script.

A 404 error is an error meaning it’s not found. (HTTP 404 - Wikipedia). This is common on literally everything in the internet.

In your case, I’m going to guess that GetUsernameFromUserId() is returning the 404 error. This is either one of two things.

  1. Roblox is actually broken - seems unlikely
  2. This returns a 404 if you don’t give a valid userid. That being said, as someone else said you need to return some other value instead. Having a default username on hand like “Null” or something return if it errors would be wise, as it lets users know something went wrong.

I looked into the listing for it here (Players | Documentation - Roblox Creator Hub) and found that.


It appears they use by, but from will return if they’re IN GAME.

So for your issue either choose to use

Players:GetNameFromUserIdAsync(userId) -- Will fetch for all users
-- or
Players:GetPlayerByUserId(userId) -- Will only return if a user is in game

Appears you have a simple typo maybe?


Can we see your full stack trace? So every error.

If pretty sure he isn’t giving a valid UserId. But, as roblox is having alot of bugs this month this can be a bug.