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

My DataStore script is printing an error 502. How to Fix This?

I Just Made a DataStore Script tho its having errors in the output, can;t figure out what it is, but it says its in the line:45

This is what it prints in the output: 502: API Services rejected request with error. HTTP unknown error (HttpError: curl:52, Server returned nothing (no headers, no data))

Here's the Script:

local DSS = game:GetService("DataStoreService"):GetDataStore("DataStoreV1")


game.Players.PlayerAdded:connect(function(Player)
	local Data = Instance.new("Folder")
	Data.Name = "Data"
	Data.Parent = Player
	
	local Clan = Instance.new("IntValue", Data)
	Clan.Name = "Clan"
	Clan.Value = 0
	Clan.Parent = Data
	
	local Class = Instance.new("IntValue", Data)
	Class.Name = "Class"
	Class.Value = 0
	Class.Parent = Data
	
	local Stats = Instance.new("Folder", Data)
	Stats.Name = "Stats"
	Stats.Parent = Data
	
	local Cash = Instance.new("IntValue", Stats)
	Cash.Name = "Cash"
	Cash.Value = 0
	Cash.Parent = Stats
	
	local Kills = Instance.new("IntValue", Stats)
	Kills.Name = "Kills"
	Kills.Value = 0
	Kills.Parent = Stats
	
	local MeleeXP = Instance.new("IntValue", Stats)
	MeleeXP.Name = "MeleeXP"
	MeleeXP.Value = 0
	MeleeXP.Parent = Stats
	
	local SwordXP = Instance.new("IntValue", Stats)
	SwordXP.Name = "SwordXP"
	SwordXP.Value = 0
	SwordXP.Parent = Stats
	
	local Key = "RbxId://"..Player.userId
	
	local StoredItems = DSS:GetAsync(Key)
	if StoredItems then
		Clan.Value = StoredItems[1]
		Class.Value = StoredItems[2]
		Cash.Value = StoredItems[3]
		Kills.Value = StoredItems[4]
		MeleeXP.Value = StoredItems[5]
		SwordXP.Value = StoredItems[6] 
	else
		local Items = {Clan.Value, Class.Value, Cash.Value, Kills.Value, MeleeXP.Value, SwordXP.Value}
		DSS:SetAsync(Key, Items)
	end
	if Clan.Value == 0 then
		Clan.Value = math.random(1, 10)
	end
end)

game.Players.PlayerRemoving:Connect(function(Player)
	local Data = Player:WaitForChild("Data")
	local Stats = Data:WaitForChild("Stats")
	local Items = {Data.Clan.Value, Data.Class.Value, Stats.Cash.Value, Stats.Kills.Value, Stats.MeleeXP.Value, Stats.SwordXP.Value}
	local Key = "RbxId://"..Player.userId
	
	DSS:SetAsync(Key, Items)
end)

1 answer

#Problem The error 502 is most likely a backend Roblox datastore error. You might have to wait a little bit because Roblox is not having a good time.

Probably because everyone is quarantined and everyone is playing roblox

2 comments

0

Hmm. That's fine, Thanks.

0

Emm no...

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