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

problem with DataStore '403: Cannot write to DataStore from studio if API access is not enabled'?

Asked by 7 years ago

i don't know what i did wrong to get this output '403: Cannot write to DataStore from studio if API access is not enabled.'

**If you need any more information about the script just comment thanks already **

the full output is: ' 14:21:54.090 - 403: Cannot write to DataStore from studio if API access is not enabled. 14:21:54.090 - Stack Begin 14:21:54.091 - Script 'ServerScriptService.Stats', Line 18 - global savedata 14:21:54.091 - Script 'ServerScriptService.Stats', Line 91 14:21:54.092 - Stack End '

line 17-18-19:

function savedata(dataname, playerid, value)
    game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, value --line 18
end

line 90 - 95

game.Players.PlayerRemoving:connect(function(player)
    savedata("Levels", player.userId, player:WaitForChild('Stats').Level.Value) -- line 91
    savedata("XP", player.userId, player:WaitForChild('Stats').XP.Value)
    savedata("AXP", player.userId, player:WaitForChild('Stats').XpNeeded.Value)
    savedata("Cor", player.userId, player:WaitForChild('Stats').Cor.Value)
end)

FULL SCRIPT:

local level = game:GetService("DataStoreService"):GetDataStore("Levels")
local xp = game:GetService("DataStoreService"):GetDataStore("XP")
local axp  = game:GetService("DataStoreService"):GetDataStore("AXP") -- amount needed

local cor = game:GetService("DataStoreService"):GetDataStore("Cor") -- money

local OHS  = game:GetService("DataStoreService"):GetDataStore("OneHandedSword")
local R  = game:GetService("DataStoreService"):GetDataStore("Rapier")
local THS  = game:GetService("DataStoreService"):GetDataStore("TwoHandedSword")

local Agility = game:GetService("DataStoreService"):GetDataStore("Agility")
local Stamina = game:GetService("DataStoreService"):GetDataStore("Stamina")
local Strength = game:GetService("DataStoreService"):GetDataStore("Strength")

---------------------------------------------------------------------------------

function savedata(dataname, playerid, value)
    game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, value)
end

game.Players.PlayerAdded:connect(function(player)
    local leader = Instance.new('Folder')
    leader.Name = "leaderstats"
    leader.Parent = player

    local Stats = Instance.new('Folder')
    Stats.Name = 'Stats'
    Stats.Parent = player

    local LevelUp = Instance.new("IntValue")
    LevelUp.Value = level:GetAsync(tostring(player.userId)) or 1
    LevelUp.Name = "Level"
    LevelUp.Parent = player:WaitForChild('Stats')

    local XpUp = Instance.new("NumberValue")
    XpUp.Value = xp:GetAsync(tostring(player.userId))
    XpUp.Name = "XP"
    XpUp.Parent = player:WaitForChild('Stats')


    local xpn = Instance.new("IntValue")
    xpn.Value = axp:GetAsync(tostring(player.userId)) or 200
    xpn.Name = "XpNeeded"
    xpn.Parent = player:WaitForChild('Stats')

    local Cor = Instance.new("NumberValue")
    Cor.Value = cor:GetAsync(tostring(player.userId)) or 0
    Cor.Name = "Cor"
    Cor.Parent = player:WaitForChild('Stats')

    local OneHandedSword = Instance.new("NumberValue")
    OneHandedSword.Value = OHS:GetAsync(tostring(player.userId)) or 1
    OneHandedSword.Name = "OneHandedSword"
    OneHandedSword.Parent = player:WaitForChild('Stats')

    local TwoHandedSword = Instance.new("NumberValue")
    TwoHandedSword.Value = THS:GetAsync(tostring(player.userId)) or 1
    TwoHandedSword.Name = "TwoHandedSword"
    TwoHandedSword.Parent = player:WaitForChild('Stats')

    local rap = Instance.new("NumberValue")
    rap.Value = R:GetAsync(tostring(player.userId)) or 1
    rap.Name = "Rapier"
    rap.Parent = player:WaitForChild('Stats')

    XpUp.Changed:connect(function()
        if player:WaitForChild("XP").Value >= player:WaitForChild("XpNeeded").Value then
            LevelUp.Value = LevelUp.Value+1
            LevelUp.Changed:connect(function()
                XpUp.Value = 0
            end)
            savedata("Levels", player.userId, LevelUp.Value)
            savedata("XP", player.userId, XpUp.Value)
            savedata("AXP", player.userId, xpn.Value)
            else
            savedata("Levels", player.userId, LevelUp.Value)
            savedata("XP", player.userId, XpUp.Value)
            savedata("AXP", player.userId, xpn.Value)
            end
        savedata("Levels", player.userId, LevelUp.Value)
        savedata("XP", player.userId, XpUp.Value)
        savedata("AXP", player.userId, xpn.Value)
    end)
    Cor.Changed:connect(function()
        savedata("Cor", player.userId, Cor.Value)
    end)
    savedata("Cor", player.userId, Cor.Value)
end)

game.Players.PlayerRemoving:connect(function(player)
    savedata("Levels", player.userId, player:WaitForChild('Stats').Level.Value)
    savedata("XP", player.userId, player:WaitForChild('Stats').XP.Value)
    savedata("AXP", player.userId, player:WaitForChild('Stats').XpNeeded.Value)
    savedata("Cor", player.userId, player:WaitForChild('Stats').Cor.Value)
end)

1 answer

Log in to vote
0
Answered by 7 years ago

Hey!

This is an easy fix, what you wanna do is go on to the place on the roblox.com website then go on the game page where it says play. Then click the 3 dots and click configure game, after that tick the option that says 'Enable Studio Access to API Services'

Hope this helps!

0
Thank you! TigerClaws454 48 — 7y
Ad

Answer this question