HTTP 404 Not Found Error

i recently created a leaderboard that basically displays global stats using an ordered data store. However, starting today, it stopped working due to this error:

14:27:24.657 - Players:GetNameFromUserId() failed because HTTP 404 (NotFound)
14:27:24.660 - Stack Begin
14:27:24.694 - Script 'ServerScriptService.PointsDataStore', Line 88
14:27:24.696 - Stack End

I suspect it might be an internal error? If so, who else is having this problem? If not, maybe something wrong with my code? Ehh, Ill just post my code anyways:

wait(3) -- precaution to prevent server loading before client

while true do
	data = {}
	local DataStorePages = PointsDataStore:GetSortedAsync(false, 12, 1, 10e30)
	local top = DataStorePages:GetCurrentPage()
	for _, v in ipairs(top) do
        local points = v.value
        local username = Players:GetNameFromUserIdAsync(v.key) --> problem here
        table.insert(data, {username, points})
   	end
	game.ReplicatedStorage.GlobalLeaderboard:FireAllClients(data)
	wait(60)
end
1 Like

Are you testing this in studio? If you are then you need to make sure that “Enable Studio Access to API Services” is checked in the game settings.

No, it has this error on the actual game client too

The answer is pretty simple: You’re requesting a UserId that doesn’t exist. I can replicate this behavior in Studio:

image

Make sure your DataStores are returning the data you expect. You’re getting a number (the error would be different otherwise, telling you there’s a type mismatch) but it might not be the value you’re expecting.

I got this error ever since I playtested with the emulator. I noticed that Player1’s UserId is -1 which I know is not a proper user Id. How do remote Player1’s Id from the data store?

You should be able to remove that key by running:

PointsDataStore:RemoveAsync(-1)

In the future, make sure you don’t store save data for players where the UserId is less than 1.

1 Like