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

testing script on team play and got weird error code?

i was testing a script on a team play. the script is for saving a table for a obby stage. but wen i test it i get a error code that does not make sense. can any one help pleas?

the error code is : 21:07:42.839 - 502: API Services rejected request with error. HTTP 403 (Forbidden)

local DataStoreService = game:GetService("DataStoreService")
	local DataStore = DataStoreService:GetDataStore("MyDataStore")
	 
	 
	game.Players.PlayerAdded:Connect(function(player)
	 
	local ack = Instance.new("Folder")
	ack.Name = "leaderstats"
	ack.Parent = player
	 
	local ack2 = Instance.new("IntValue")
	ack2.Name = "Stage"
	ack2.Parent = ack
	 
	local data
	 
	local success, errormassage = pcall(function()
	    data = DataStore:GetAsync(player.UserId.."-stage")
	    end)
	    if success then
	        ack2 = data
	    else
	        print("there was an error whilst getting your data")
	        warn(errormassage)	    end
	 
	local test = player.leaderstats.Stage.Value
	 	 
	 
	end)
	 
	function oa(object)
	    wait()
	local player = game.Players:playerFromCharacter(object)
	if player ~= nil then
	local ls = player.leaderstats
	local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
	print("gah")
	object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0)
	 
	if sl ~= nil then
	object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
	end
	end
	end
	 
	game.Workspace.ChildAdded:connect(oa)
	 
	game.Players.PlayerRemoving:Connect(function(player)
	 
	    local success, errormessage = pcall(function()
	        DataStore:SetAsync(player.UserId.."-stage",player.leaderstats.Stage.Value)
	    end)
	     if success then
	        print("Player Data successfully saved!")
	    else
	        print("there was an error when saving data")
	        warn(errormessage) 
	    end
	end)


1 answer

✓ Accepted answer

By default, "Enable access to API services" is set to false. In that case, data stores will not work when you test the game in Roblox studio, and they will only work in the live version. To fix the problem, go to your game settings in the Roblox develop page, and tick the box that says "Enable access to API services". That way, data stores will work as usual, even on Roblox studio.

I hope this is of some help.

3 comments

0

thx for the help but im doing this on a friends game and he says its enabled but for me it shows that its not enabled but it wont let me change it?

0

Try asking your friend about it, maybe he/she knows what is going on. (Or at least has a clue of why that is happening)

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