Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

502: API Services rejected request with error. HTTP 403 (Forbidden), does anybody know a fix?

Asked by 4 years ago

So, I'm trying to make a DataStore for cash in a game. For some reason, even after enabling API Services in the Studio settings, I still get the error message:

"502: API Services rejected request with error. HTTP 403 (Forbidden)"

(Proof of enabling API Services: https://prnt.sc/t1l1p7)

Here is my code:

local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local cashDataStore = DataStoreService:GetDataStore("cashDataStore")

game.Players.PlayerAdded:Connect(function(player)
    cashCounter = player.PlayerGui:WaitForChild("StarterScreenUI").sideGui.Frame.cash

    local cashData
    local success, errormessage = pcall(function()
        cashData = cashDataStore:GetAsync(player.UserId.."-cash")
    end)

    if success then
        cashCounter.Text = "$"..cashData
    else
        cashDataStore:SetAsync(player.UserId.."-cash",200)
        cashData = cashDataStore:GetAsync(player.UserId.."-cash")
        cashCounter.Text = "$"..cashData
    end

    return cashCounter
end)

game.Players.PlayerRemoving:Connect(function(player)
    local success, errormessage = pcall(function()
        cashDataStore:SetAsync(player.UserId.."-cash",cashCounter.Text)
    end)

    if success then
        print("Success")
    else
        warn(errormessage)
    end
end)

ReplicatedStorage.Events.PurchaseSaveEvent.OnServerEvent:Connect(function()

end)

while wait(2) do
    cashData = cashData + 1
    cashCounter.Text = "$"..cashData
    print(cashCounter.Text)
end
0
Whats the point of saving to the datastore if a Error occured? Luka_Gaming07 534 — 4y
0
Enable API Service usingg the settings. Dovydas1118 1495 — 4y
0
@Dovydas118, he said he already enabled API service. JesseSong 3916 — 4y
View all comments (2 more)
0
@JesseSong It's in my own game. No TC enabled. Valtonian 43 — 4y
0
Are you sure? Because I don't know the answer to this other than Team create. JesseSong 3916 — 4y

Answer this question