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.
–Error–
[Players:GetNameFromUserId() failed because HTTP 404 (NotFound)]
local DataService = game:GetService("DataStoreService")
local DataStore = DataService:GetDataStore("Doesnotd Martterrih now")
game.Players.PlayerAdded:Connect(function(player)
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
end)
if success then
days.Value = Days_Data
print("Retrived")
elseif errorMessage then
warn(errorMessage,"Error Message")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
print(player," Has Left")
local days = player.leaderstats.Days.Value
local success, errorMessage = pcall(function()
DataStore:SetAsync(player.UserId.. "days", days) --(key, keyword, value)
end)
if success then
print("All Saved")
else
warn(errorMessage) --warn is like print, except in orange text, showing where the warning is
end
end)
local success, errorMessage = pcall(function()
Days_Data = DataStore:GetAsync(player.UserId.. "days") --(key, keyword) --you should make it a keyword, rather than a value
end)
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?
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.
Roblox is actually broken - seems unlikely
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.