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

Why does the data store error when saving data when player leaves?

Asked by
LuaDLL 253 Moderation Voter
4 years ago

Script:

function onPlayerRemove(player)

    --//Variables\\--
    local Key = "%^&$#" ..player.UserId
    local SpaceCoins = player.leaderstats.SpaceCoins
    local EvoTokens = player.OtherData.EvoTokens
    local Evolutions = player.OtherData.Evolutions
    local Equipped = player.Equipped
    local Pets = player.Pets

    local PetTable = {}

    for i,v in pairs(Pets:GetChildren()) do
        table.insert(PetTable, v.Value)
    end

    local DataTable = {
        SpaceCoins.Value,
        EvoTokens.Value,
        Evolutions.Value,
        PetTable,
        Equipped.Value
    }

    --//Save Player Data\\--
    PlayerData:SetAsync(Key, DataTable)

    print("Data Saved For " ..player.Name)
end

game.Players.PlayerRemoving:Connect(onPlayerRemove)

Error: 20:13:15.097 - 502: API Services rejected request with error. HTTP 0 (HTTP 403)

1 answer

Log in to vote
1
Answered by
mc3334 649 Moderation Voter
4 years ago

Give studio access to datastore services by doing the following:

1: Access the game settings in studio 2: Enable the checkbox "Allow studio to access API services"

This should fix your issue. If it doesent, please comment here and I will continue to help.

Ad

Answer this question