problem with DataStore '403: Cannot write to DataStore from studio if API access is not enabled'?
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:
1 | function savedata(dataname, playerid, value) |
2 | game:GetService( "DataStoreService" ):GetDataStore(dataname):SetAsync(playerid, value |
line 90 - 95
1 | game.Players.PlayerRemoving:connect( function (player) |
2 | savedata( "Levels" , player.userId, player:WaitForChild( 'Stats' ).Level.Value) |
3 | savedata( "XP" , player.userId, player:WaitForChild( 'Stats' ).XP.Value) |
4 | savedata( "AXP" , player.userId, player:WaitForChild( 'Stats' ).XpNeeded.Value) |
5 | savedata( "Cor" , player.userId, player:WaitForChild( 'Stats' ).Cor.Value) |
FULL SCRIPT:
01 | local level = game:GetService( "DataStoreService" ):GetDataStore( "Levels" ) |
02 | local xp = game:GetService( "DataStoreService" ):GetDataStore( "XP" ) |
03 | local axp = game:GetService( "DataStoreService" ):GetDataStore( "AXP" ) |
05 | local cor = game:GetService( "DataStoreService" ):GetDataStore( "Cor" ) |
07 | local OHS = game:GetService( "DataStoreService" ):GetDataStore( "OneHandedSword" ) |
08 | local R = game:GetService( "DataStoreService" ):GetDataStore( "Rapier" ) |
09 | local THS = game:GetService( "DataStoreService" ):GetDataStore( "TwoHandedSword" ) |
11 | local Agility = game:GetService( "DataStoreService" ):GetDataStore( "Agility" ) |
12 | local Stamina = game:GetService( "DataStoreService" ):GetDataStore( "Stamina" ) |
13 | local Strength = game:GetService( "DataStoreService" ):GetDataStore( "Strength" ) |
17 | function savedata(dataname, playerid, value) |
18 | game:GetService( "DataStoreService" ):GetDataStore(dataname):SetAsync(playerid, value) |
21 | game.Players.PlayerAdded:connect( function (player) |
22 | local leader = Instance.new( 'Folder' ) |
23 | leader.Name = "leaderstats" |
24 | leader.Parent = player |
26 | local Stats = Instance.new( 'Folder' ) |
30 | local LevelUp = Instance.new( "IntValue" ) |
31 | LevelUp.Value = level:GetAsync( tostring (player.userId)) or 1 |
32 | LevelUp.Name = "Level" |
33 | LevelUp.Parent = player:WaitForChild( 'Stats' ) |
35 | local XpUp = Instance.new( "NumberValue" ) |
36 | XpUp.Value = xp:GetAsync( tostring (player.userId)) |
38 | XpUp.Parent = player:WaitForChild( 'Stats' ) |
41 | local xpn = Instance.new( "IntValue" ) |
42 | xpn.Value = axp:GetAsync( tostring (player.userId)) or 200 |
44 | xpn.Parent = player:WaitForChild( 'Stats' ) |
46 | local Cor = Instance.new( "NumberValue" ) |
47 | Cor.Value = cor:GetAsync( tostring (player.userId)) or 0 |
49 | Cor.Parent = player:WaitForChild( 'Stats' ) |
51 | local OneHandedSword = Instance.new( "NumberValue" ) |
52 | OneHandedSword.Value = OHS:GetAsync( tostring (player.userId)) or 1 |
53 | OneHandedSword.Name = "OneHandedSword" |
54 | OneHandedSword.Parent = player:WaitForChild( 'Stats' ) |
56 | local TwoHandedSword = Instance.new( "NumberValue" ) |
57 | TwoHandedSword.Value = THS:GetAsync( tostring (player.userId)) or 1 |
58 | TwoHandedSword.Name = "TwoHandedSword" |
59 | TwoHandedSword.Parent = player:WaitForChild( 'Stats' ) |
61 | local rap = Instance.new( "NumberValue" ) |
62 | rap.Value = R:GetAsync( tostring (player.userId)) or 1 |
64 | rap.Parent = player:WaitForChild( 'Stats' ) |
66 | XpUp.Changed:connect( function () |
67 | if player:WaitForChild( "XP" ).Value > = player:WaitForChild( "XpNeeded" ).Value then |
68 | LevelUp.Value = LevelUp.Value+ 1 |
69 | LevelUp.Changed:connect( function () |
72 | savedata( "Levels" , player.userId, LevelUp.Value) |
73 | savedata( "XP" , player.userId, XpUp.Value) |
74 | savedata( "AXP" , player.userId, xpn.Value) |
76 | savedata( "Levels" , player.userId, LevelUp.Value) |
77 | savedata( "XP" , player.userId, XpUp.Value) |
78 | savedata( "AXP" , player.userId, xpn.Value) |
80 | savedata( "Levels" , player.userId, LevelUp.Value) |
81 | savedata( "XP" , player.userId, XpUp.Value) |
82 | savedata( "AXP" , player.userId, xpn.Value) |
84 | Cor.Changed:connect( function () |
85 | savedata( "Cor" , player.userId, Cor.Value) |
87 | savedata( "Cor" , player.userId, Cor.Value) |
90 | game.Players.PlayerRemoving:connect( function (player) |
91 | savedata( "Levels" , player.userId, player:WaitForChild( 'Stats' ).Level.Value) |
92 | savedata( "XP" , player.userId, player:WaitForChild( 'Stats' ).XP.Value) |
93 | savedata( "AXP" , player.userId, player:WaitForChild( 'Stats' ).XpNeeded.Value) |
94 | savedata( "Cor" , player.userId, player:WaitForChild( 'Stats' ).Cor.Value) |