I was testing my game and realized that my data was reset for most of my leaderstats.

I have these leaderstats and the Star Fragments and Wins reset (I use a separate script for Checkpoints). I have 2 places in my game (2 worlds) and this happened on the second one. When I tried testing on the first one, I was given these messages:
DataStoreService: AccessForbidden: Access forbidden. API: GetAsync, Data Store: DataStore
and
API Services rejected request with error. Error code: 0 Reason: Access forbidden. - Server - DataManager:34
I have API access enabled on both places and the DataStore worked like an hour ago with no problems. The datastore seems to be working now but I don’t want any players to have their data reset like this. Does anyone know what the cause of this is?
Here is the datastore code:
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local dataStore = DSS:GetDataStore("DataStore")
local leaderstatsModule = require(script:WaitForChild("Leaderstats"))
local defaults = {
["Star Fragments"] = 0,
Wins = 0,
Helmet = "White",
Tag = "White",
Hat = nil,
}
local module = {}
function module.LoadData(player: Player)
leaderstatsModule:Create(player)
local key = "Player_"..player.UserId
local dataAttempts = 5
local dataTable
repeat
dataAttempts -= 1
local success, errorMessage = pcall(function()
dataTable = dataStore:GetAsync(key)
end)
if not success then
warn(errorMessage)
end
until success or dataAttempts == 0
local leaderstats = player:WaitForChild("leaderstats")
local starFragments = leaderstats:WaitForChild("Star Fragments")
local wins = leaderstats:WaitForChild("Wins")
local helmet = player:WaitForChild("HelmetColor")
local tag = player:WaitForChild("TagColor")
local hat = player.Hats:WaitForChild("HatEquipped")
if dataTable ~= {} and dataTable ~= nil then
starFragments.Value = dataTable["Star Fragments"]
wins.Value = dataTable.Wins
helmet.Value = dataTable.Helmet
tag.Value = dataTable.Tag
hat.Value = dataTable.Hat
else
starFragments.Value = defaults["Star Fragments"]
wins.Value = defaults.Wins
helmet.Value = defaults.Helmet
tag.Value = defaults.Tag
hat.Value = defaults.Hat
end
end
function module.UpdateData(player: Player)
local key = "Player_"..player.UserId
local dataAttempts = 3
local leaderstats = player:WaitForChild("leaderstats")
local starFragments = leaderstats:WaitForChild("Star Fragments")
local wins = leaderstats:WaitForChild("Wins")
local helmet = player:WaitForChild("HelmetColor")
local tag = player:WaitForChild("TagColor")
local hat = player.Hats:WaitForChild("HatEquipped")
repeat
dataAttempts -= 1
local success, errorMessage = pcall(function()
dataStore:UpdateAsync(key, function(oldData)
local newData
if oldData ~= nil then
newData = {
DataId = oldData.DataId + 1,
["Star Fragments"] = starFragments.Value,
["Wins"] = wins.Value,
["Helmet"] = helmet.Value,
["Tag"] = tag.Value,
["Hat"] = hat.Value,
}
else
newData = {
DataId = 0,
["Star Fragments"] = starFragments.Value,
["Wins"] = wins.Value,
["Helmet"] = helmet.Value,
["Tag"] = tag.Value,
["Hat"] = hat.Value
}
end
return newData
end)
end)
if not success then
warn(errorMessage)
end
until success or dataAttempts == 0
end
return module