I am trying to make data stores in my game and it keeps popping up with this message, “502: API Services rejected request with error. HTTP 403 (Forbidden)”.
The error occurs on line 25
local DSS = game:GetService("DataStoreService")
local datastore = DSS:GetDataStore("GeneralSaveData", "Players")
function generateDataKey(player)
local ret = "uid_" .. player.userId
return ret
end
function generateDataTable(player)
local dataTable = {
Coins = game.StarterPack.PlayerAssets.Value.Value,
}
return dataTable
end
function saveDataForPlayer(player)
local key = generateDataKey(player)
local data = generateDataTable(player)
datastore:SetAsync(key, data)
end
function loadDataForPlayer(player)
local key = generateDataKey(player)
local data = datastore:GetAsync(key)
inputDataToPlayer(player, data)
end
function inputDataToPlayer(player, data)
game.StarterPack.PlayerAssets.Value.Value = data.Coins
end
game.Players.PlayerAdded:Connect(function(player)
loadDataForPlayer(player) -- loads when join
game.StarterPack.PlayerAssets.Value.Value.Changed:Connect(function()
saveDataForPlayer(player) -- saves when wins changes
end)
end)
game.Players.PlayerRemoving:Connect(saveDataForPlayer) -- saves when leave

3 comments
This seems to have worked but now it says "Workspace.Script:30: attempt to index nil with 'Coins' " on line 30
try using an if statement to see if the key is in the datastore. something like if data then, since it might not exist.
it might be because you defined "data" in a different function and not the current function on line 30 so it doesn't know about this other variable