Error with datastore? Autosave leaderboard

Hey there. I’m getting an error and I am not sure how to fix it

502: API Services rejected request with error. HTTP 403 (Forbidden) - Server - Leaderstats:11

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("MoneyStats") -- Change this with a different name.

game.Players.PlayerAdded:Connect(function(Player)
	local Leaderstats = Instance.new("Folder", Player)
	Leaderstats.Name = "leaderstats"
	local Currency = Instance.new("IntValue", Leaderstats)
	Currency.Name = "Skill" -- Change "Money" with your currency.
	Currency.Value = 0

	local Data = DataStore:GetAsync(Player.UserId)
	if Data then
		Currency.Value = Data -- Change this if you have added more currencies.
	end
end)

game.Players.PlayerRemoving:Connect(function(Player)
	DataStore:SetAsync(Player.UserId, Player.leaderstats.Skill.Value) -- Change "Money" with your currency.
end)

Thank you for the help.

2 Likes

Did you Enable Studio Access to API Services?

Did you enable dataStores in studio?

no, i do not have http requesst on

im not sure where i go to turn that on

Game settings in home tab.

Then navigate to security.

i turned http requests on but i am still getting the error

Hm. Let me quickly retype your code.

wait does api services fix it? i dont have it on

Um. You can try. Not sure though.

You need to enable the services in the game settings.

1 Like

That’s what u do. Since it’s an api and http.

Yeah, the error went away! (30Charr)

Alright. Make sure to mark the solution.