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

DataStore not saving, printing error message?

On line 17 I get print error I dont know why this is happening? I get error 502: API Services rejected request with error. HTTP 403 (Forbidden)

local DS = game:GetService("DataStoreService")
local DS1 = DS:GetDataStore("SaveJoins")

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = player:WaitForChild("leaderstats")
    local joins = Instance.new("IntValue")
    joins.Name = "Joins"
	joins.Parent = leaderstats
	local PlayerUserId = "Player_"..player.UserId
	
	local data
	local success, errormessage = pcall(function()
		data = DS1:GetAsync(PlayerUserId)
	end)
	if success then
		joins.Value = data + 1
	else
		print("error")
		warn(errormessage)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local PlayerUserId = "Player_"..player.UserId
	local data = player.leaderstats.Joins.Value
	local success, errormessage = pcall(function()
		DS1:SetAsync(PlayerUserId, data)
	end)
	if success then
		print("success")
	else
		print("error")
		warn(errormessage)
	end
end)

2 answers

Go to Game Settings in studio and press Options. Then, turn "Enable API Services" on.

Saw on line 11 I put local data.. I removed it and it worked?

1 comment

0

Oh... that's strage.

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