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 Leaderstats script keep getting strange Errors? HTTP of some kind...

My leaderstats script keeps getting an error saying 'API Services rejected request with error. HTTP 403 (Forbidden)' Here's the script:

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("MoneySaveSystem")
local ds2 = DataStore:GetDataStore("ExperienceSaveSystem")

game.Players.PlayerAdded:Connect(function(player)
	local leader = Instance.new("Folder")
	leader.Name = "leaderstats"
	leader.Parent = player
	
	local Inventory = Instance.new("Folder")
	Inventory.Name = player.Name
	Inventory.Parent = game.ReplicatedStorage.PlayerInventories
	
	local Stats = Instance.new("Folder")
	Stats.Name = player.Name
	Stats.Parent = game.ReplicatedStorage.PlayerStats
	
	local Money = Instance.new("IntValue")
	Money.Name = "Money"
	Money.Parent = leader
	Money.Value = ds:GetAsync(player.UserId) or 0
	print(player.Name.."'s Money was successfully loaded!")
	ds:SetAsync(player.UserId, Money.Value)
	
	local Experience = Instance.new("IntValue")
	Experience.Name = "Experience"
	Experience.Parent = leader
	Experience.Value = ds2:GetAsync(player.UserId) or 0
	print(player.Name.."'s Experience was successfully loaded!")
	ds2:SetAsync(player.UserId, Experience.Value)
end)

game.Players.PlayerRemoving:Connect(function(player)
	game.ReplicatedStorage.PlayerInventories[player.Name]:Destroy()
	game.ReplicatedStorage.PlayerStats[player.Name]:Destroy()
	ds:SetAsync(player.UserId, player.leaderstats.Money.Value)
	print(player.Name.."'s Money was successfully saved!")
	ds2:SetAsync(player.UserId, player.leaderstats.Experience.Value)
	print(player.Name.."'s Experience was successfully saved!")
end)

Li'l help pls. Thanks

2 comments

0

You need to enable studio access to HTTP services at game configuration

0

I have

1 answer

You might want to use a pcall in your code and Enable Studio access to API Services by going to Home > Game Settings > Permissions > Enable Studio Access to API Services and tick it.

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