When ever I try to save using datastores I get this error:
502: API Services rejected request with error. HTTP 403 (Forbidden) Stack Begin Script 'ServerScriptService.PlayerStast', Line 20 Stack End
this is my code:
local DSS = game:GetService("DataStoreService") --Data stores local ds = DSS:GetDataStore("Cash") ---Cash game.Players.PlayerAdded:Connect(function(player) --PlayerStats local stats = Instance.new("Folder") stats.Name = "PlayerStats" stats.Parent = player --Cash local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Parent = stats cash.Value = ds:GetAsync(player.UserId.."-cash") or 100 cash.Changed:Connect(function() ds:SetAsync(player.UserId.."-cash",player.PlayerStats.Cash.Value) end) end) game.Players.PlayerRemoving:Connect(function(player) ds:SetAsync(player.UserId.."-cash",player.PlayerStats.Cash.Value) end)
Hello there, simple solution:
1. Go to the Develop page 2.Click on the Games tab and find your game 3.Click on the gear drop down and click "Configure" 4.Check the box labeled "Enable Studio Access to API Services:"
The reason for this is because ROBLOX Studio needs Acess to the API services inorder to read and send data from the client, thus requiring you to permit them to do so. Other than that the code will not work, especially in studio. Follow the steps in order to solve your problem.
you should enable api services in order to do that you must go to game settings in the home tab in roblox studio then go to options and enable api services please accept this answer :)))