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

Why is my data store not working for studio and just throws this error?

Asked by 6 years ago

I'm trying to make this script to add $100 every minute to the player's wallet. I also want to store and retrieve money for the player in a data storage. The problem is, is that studio is still giving me an error that says, "API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 You do not have permission to manage this place. You don't have edit permissions.))". Even though I get this error I have already allowed roblox studio access to API services. I am working on this project with my brother also using team create.

local playerService = game:GetService("Players")
local dataStore = game:GetService("DataStoreService"):GetDataStore("Currency")

local function StartMoneyCounter(player, value)
    local money = value
    spawn(function()
        while true do
            money = money + 100
            player.PlayerGui.MoneyScreenGui.MoneyLabel.Text = tostring(money)
            wait(60)
        end
    end)
end

playerService.PlayerAdded:connect(function(player)
    local uniqueKey = "id-"..player.userId
    local savedData = dataStore:GetAsync(uniqueKey)
    if savedData then
        StartMoneyCounter(player, savedData[1])
    else
        local saveNumber = {tonumber(player.PlayerGui.MoneyScreenGui.MoneyLabel.Text)}
        dataStore:SetAsync(uniqueKey, saveNumber)
        StartMoneyCounter(player, saveNumber[1])
    end
end)

playerService.PlayerRemoving:connect(function(player)
    local uniqueKey = "id-"..player.userId
    local saveTable = {tonumber(player.PlayerGui.MoneyScreenGui.MoneyLabel.Text)}
    dataStore:SetAsync(uniqueKey, saveTable)
end)
0
The Owner only has the ability to use HttpService and DataStoreService in studio. If you want to also use it, you are going to have to play the game. MizeryGFX 15 — 6y
0
thanks I was able to get it working! Troloolooolooll 9 — 6y
0
:connect() is deprecated now and only works in studio. Instead, use :Connect(). (I don't really like the update) hiimgoodpack 2009 — 6y

Answer this question