Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Strange save request error not allowing datastores?

i get this error : 11:45:57.468 - 502: API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 Forbidden))

every time i execute this code and i do have api on and filtering enabled on

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player)
 local leader = Instance.new("Folder",player)
 leader.Name = "leaderstats"
 local Cash = Instance.new("IntValue",leader)
 Cash.Name = "Miner Bucks"
 Cash.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, Cash.Value)
 Cash.Changed:connect(function()
  ds:SetAsync(player.UserId, Cash.Value)
 end)
end)


game.Players.PlayerRemoving:connect(function(player)
 ds:SetAsync(player.UserId, player.leaderstats.Cash.Value)
end)

2 comments

1

Do you own the place?

0

connect and the parent argument to Instance.new are deprecated. Switch to Connect and assign the parent last instead of first, assigning first can down the performance.

1 answer

This should solve your problem, and you should also go in studio>the home tab at the top> Game Settings>Security>Allow HTTP Requests, and turn it to ON.

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CashSaveSystem")

game:GetService("Players").PlayerAdded:Connect(function(player)
 local leader = Instance.new("Folder",player)
 leader.Name = "leaderstats"
 local Cash = Instance.new("IntValue",leader)
 Cash.Name = "Miner Bucks"
 Cash.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, Cash.Value)
 Cash.Changed:connect(function()
  ds:SetAsync(player.UserId, Cash.Value)
 end)
end)


game:GetService("Players").PlayerRemoving:Connect(function(player)
 ds:SetAsync(player.UserId, player.leaderstats.Cash.Value)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.