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

My leaderboard script is not working properly?

Probably Something with Datastore.. Error is

 17:24:27.903 - 502: API Services rejected request with error. HTTP 403 (Forbidden)

--

local PointData = game:GetService("DataStoreService"):GetDataStore("PointData")
local RebirthData = game:GetService("DataStoreService"):GetDataStore("RebirthData")

game.Players.PlayerAdded:Connect(function(player)
	local LB = Instance.new("IntValue")
	LB.Name = "leaderstats"
	LB.Parent = player
	
	local p = Instance.new("IntValue")
	p.Name = "Points"
	p.Parent = LB
	p.Value = PointData:GetAsync(player.UserId) or 0
	
	local r = Instance.new("IntValue")
	r.Name = "Rebirths"
	r.Parent = LB
	r.Value = RebirthData:GetAsync(player.UserId) or 0
end)

game.Players.PlayerRemoving:Connect(function(player)
	
	PointData:SetAsync(player.UserId, player.leaderstats.Points.Value)
	RebirthData:SetAsync(player.UserId, player.leaderstats.Rebirths.Value)
	
end)

1 answer

✓ Accepted answer

The service "Datastore" uses API services. When you publish a game, API services will not be accepted, unless you change it in the game settings. You have to enable API services to be able to use DataStoreService. You have to publish your game to be able to enable API services.

Hope this helped!

1 comment

0

Thanks!

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