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

502: API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 Forbidden))?

Asked by 6 years ago
Edited 6 years ago
local SaveAddition = script.SaveAddition.Value -- Just a string value

    DataStore = game:GetService("DataStoreService"):GetDataStore("OnePiece"..SaveAddition)

        local IntegerValues = {
            "Bounty", "Berry", "Banking", "Swimming", "SwimmingExp", "SwimmingMaxExp", 
            "HasCharacter", "Bullets", "Rum", "Crates", "HairStyle", "Quest", "Apples", "Corn", 
            "Wheat", "CopperOre", "IronOre", "Handles", "AppleSlices"
            }

        local StringValues = {
            "DevilFruit", "Race", "Imprisoned", "Gender", "Occupation", "Skin"
            }

        local NumberValues = {
            "KenHaki", "BusoHaki", "HaoHaki", "HandWork", "FootWork", "SkinColorR", "SavedLocationX", 
            "SavedLocationY", "SavedLocationZ", "Energy", "MaxEnergy", "Health", "MaxHealth", "Stomach", 
            "MaxStomach", "Oxygen", "MaxOxygen", "Cooking", "Swordsmanship", "PowerOutput"
            }


function SaveFunction(Player, DataType, DataHold, Table)
    local key = tostring(Player.userId..DataType)
        DataStore:UpdateAsync(key, function(oldD)
            D = {}
                for i = 1, #Table do
                    local Val = DataHold[Table[i]]
                    table.insert(D, i, Val.Value)
                end
            D = D
            return D
        end)    
end

function Save(Player)
    while true do
            wait(15)
        local Data = game.ReplicatedStorage.DataFolder[Player.Name.."Data"]
        SaveFunction(Player, "Integer", Data, IntegerValues)
        SaveFunction(Player, "String", Data, StringValues)
        SaveFunction(Player, "Number", Data, NumberValues)

    end
end

function onPlayerEntered(Player)
        local DataStorage = game.ReplicatedStorage.DataFolder

        if DataStorage:FindFirstChild(Player.Name.."Data") ~= nil then
            DataStorage[Player.Name.."Data"]:remove()
        end

        local Data = Instance.new("IntValue", DataStorage) -- All of the Values for Data Go Inside of here.
                 Data.Name = Player.Name.."Data"


            -- Insert Integer Values (If There's Any.)  
                for InsertIntegers = 1, #IntegerValues do
                    local NewInteger = Instance.new("IntValue", Data)
                        NewInteger.Name = IntegerValues[InsertIntegers]
                        NewInteger.Value = 0
                end
                -- Insert String Values (If There's Any.)   
                for InsertStrings = 1, #StringValues do
                    local NewString = Instance.new("StringValue", Data)
                        NewString.Name = StringValues[InsertStrings]
                        NewString.Value = ""
                end
                -- Insert Number Values (If There's Any.)   
                for InsertNumbers = 1, #NumberValues do
                    local NewNumber = Instance.new("NumberValue", Data)
                        NewNumber.Name = NumberValues[InsertNumbers]
                        NewNumber.Value = 0
                end

    if DataStore:GetAsync(Player.userId.."Integer") ~= nil then
        D = DataStore:GetAsync(Player.userId.."Integer")
        for i, v in pairs(D) do
            Data:FindFirstChild(IntegerValues[i]).Value = v
        end
    else
    end

    if DataStore:GetAsync(Player.userId.."String") ~= nil then
        D = DataStore:GetAsync(Player.userId.."String")
        for i, v in pairs(D) do
            Data:FindFirstChild(StringValues[i]).Value = v
        end
    else
    end

    if DataStore:GetAsync(Player.userId.."Number") ~= nil then
        D = DataStore:GetAsync(Player.userId.."Number")
        for i, v in pairs(D) do
            Data:FindFirstChild(NumberValues[i]).Value = v
        end
    else
    end

    local RunSave = coroutine.wrap(Save)
        RunSave(Player)

end

game.Players.ChildAdded:connect(onPlayerEntered)

This is obviously for a one piece game.

I'm throwing this error 16:18:09.489 - 502: API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 Forbidden)) 16:18:09.490 - Stack Begin 16:18:09.490 - Script 'Workspace.World_Scripts.Core.TomNewDataStore', Line 76 16:18:09.491 - Stack End

and I'm not quite sure what could be causing it. This works fine for me when I play the game, it all saves with no issues. However this throws the error whenever anyone else trys to play.

This script WORKS for ME ONLY, when I enter the game, IN THE GAME SERVER. However when anyone else comes into THE GAME SERVER, it doesn't work for them. I do indeed have the API ENABLED.

I've also tried to run a Local Server with the Network Simulator and got this error

19:34:08.321 - 502: API Services rejected request with error: HTTP 0 (HTTP 418 (Network Simulator))
19:34:08.322 - Stack Begin
19:34:08.323 - Script 'Workspace.World_Scripts.Core.TomNewDataStore', Line 24 - global SaveFunction
19:34:08.324 - Script 'Workspace.World_Scripts.Core.TomNewDataStore', Line 40
19:34:08.325 - Stack End
19:34:08.401 - Network Simulator Http Latency:0.52s, request type:DataStore
19:34:09.040 - Network Simulator Http Latency:0.55s, request type:DataStore
19:34:09.142 - Network Simulator Http Failed, request type:DataStore

I've also managed to pull this error using a mock acc in the studio to check it

20:36:05.654 - 502: API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 Forbidden))
20:36:05.654 - Stack Begin
20:36:05.655 - Script 'Workspace.World_Scripts.Core.TomNewDataStore', Line 79
20:36:05.656 - Stack End

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago
0
Yeah but that doesn't solve the issue. I've already ensured all of my API's are enabled for DataStores. I've also used this extact script in other games. SnowFunsize 55 — 6y
0
Are you talking about play mode in studio, or in an actual game server? mattscy 3725 — 6y
0
into a game server SnowFunsize 55 — 6y
Ad

Answer this question