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

why does my data store script not work? (added this to be more specific)

i tried to use data store for first time and everything seems ok but i keep getting error messages 12:31:38.285 - 502: API Services rejected request with error. HTTP 403 (Forbidden) 12:31:52.571 - ScriptNavigationHandler : No script currently available. i made sure to allow studio access to api services but it still gives me errors

local DataStoreService = game:GetService("DataStoreService")

local Ticks = DataStoreService:GetDataStore("Ticks")

game.Players.PlayerAdded:Connect(function(player)
	
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = player
	
	local ticks = Instance.new("IntValue")
	ticks.Name = "Ticks"
	ticks.Parent = stats
	
	local data
	local success, errormessage = pcall(function()
		data = Ticks:GetAsync(player.UserId.."-ticks")
	end)
		
	if success then
		ticks.Value = data
	else
		print("There was an error while getting data")
		warn(errormessage)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	
	local success, errormessage = pcall(function()
		Ticks:SetAsync(player.UserId.."-ticks", player.leaderstats.Ticks.Value)
	end)
		
	if success then
		print("Player Data Successfully Saved")
	else
		print("There was an error while saving data")
		warn(errormessage)
	end

end)

1 answer

the problem isnt with the script. its with the game. To keep eevrything stable or something, the API services are off by default. To use and edit datastores in roblox studio, API serviced must be enabled. its easy to enable it.

link

go to this link. scroll to the bottom. then go up a little, thers an area at the bottom that tells you how to enable it.

if your too lazy to click one link, then enable it by doing this.

From the Home tab in Studio, open the Game Settings window.

In the Options section of game Setting Window, turn on Enable Studio Access to API Services.
Click Save to register your changes

1 comment

0

i turned them on before i posted this and it didnt wokr

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