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)
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.