API Services rejected request

Hey so I’m trying to make a system that checks if a code already exists. If it doesn’t then it’ll add the code and the player’s ID to the dataStore. Why am I getting this error? 502: API Services rejected request with error. HTTP 403 (Forbidden)

local DataStore = game:GetService("DataStoreService")
local Classes = DataStore:GetDataStore("Classes")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game.Players:GetPlayers()

-- Creating a class
local function createCode(Player,Code,success)
	local code = Code
	members = Classes:GetAsync(code)--Check if the code is already in use
	if not members then
		Classes:SetAsync(code, {Player.UserId})
		return success
	else
		--Tell the user the code is taken, class codes must be unique
		return 
	end
end

ReplicatedStorage.CreateCode.OnServerInvoke = createCode

Thanks!

I don’t think datastore works in studio

1 Like

Adding on to @Sniperkaos’s post:

  • DataStores cannot be used in a save file studio session

  • DataStores can only be used in published-place studio file where the game also has this setting enabled:

4 Likes