Datastore randomly stopped working

Today when I went into studio to work on my game and tested it, I noticed that the leaderbords werent loading the saved data so I went into the main game and played it it was also happening the data was not loading it was wierd since I didint change the save script at all any idea on why this could be happening?

Thanks!

The Save script:

local DataStoreService = game:GetService("DataStoreService")
local SaveSlot = DataStoreService:GetDataStore("SaveSlotTesting")


game.Players.PlayerAdded:Connect(function(player)
	
		

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	
	
	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = leaderstats

	
	local Gems = Instance.new("IntValue")
	Gems.Name = "Gems"
	Gems.Parent = leaderstats


	
	local PlayerUserId = player.UserId 
	
	       	
	local LoadedSaveData 
	local success, errormessage = pcall(function()
		LoadedSaveData = SaveSlot:GetAsync(PlayerUserId) 
	end)
	
	if success then
		
		if  LoadedSaveData then
			
			player.leaderstats.Level.Value = LoadedSaveData.LevelSaveData
			player.leaderstats.Gems.Value = LoadedSaveData.GemsSaveData
			end
		
		
	end
	
	----------------------------------
		

end)



game.Players.PlayerRemoving:Connect(function(player)
	
	local PlayerUserId = player.UserId 
	
	local SavedData = {---
		
		LevelSaveData = player.leaderstats.Level.Value,
		GemsSaveData = player.leaderstats.Gems.Value  
		
	}
	
	
	local success, errormessage = pcall(function()
		SaveSlot:SetAsync(PlayerUserId, SavedData)
	end)
	
	
	
end)

--------------------------------------

Do you get any errors? Also, I’d recommend using UpdateAsync over SetAsync as it validates the data passed through it.

I dont get any errors at all

30char30

Try debugging it for me, I may be missing something super simple.

local DataStoreService = game:GetService("DataStoreService")
local SaveSlot = DataStoreService:GetDataStore("SaveSlotTesting")


game.Players.PlayerAdded:Connect(function(player)
	
		

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	
	
	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = leaderstats

	
	local Gems = Instance.new("IntValue")
	Gems.Name = "Gems"
	Gems.Parent = leaderstats

	print("instances created")


	
	local PlayerUserId = player.UserId 
	
	       	
	local LoadedSaveData 
	local success, errormessage = pcall(function()
		LoadedSaveData = SaveSlot:GetAsync(PlayerUserId) 
	end)
	
	if success then
		print("success")
		if  LoadedSaveData then
			print("loaded data")
			player.leaderstats.Level.Value = LoadedSaveData.LevelSaveData
			player.leaderstats.Gems.Value = LoadedSaveData.GemsSaveData
			print("set data")
			end
		
		
	end
	
	----------------------------------
		

end)



game.Players.PlayerRemoving:Connect(function(player)
	
	local PlayerUserId = player.UserId 
	
	local SavedData = {---
		
		LevelSaveData = player.leaderstats.Level.Value,
		GemsSaveData = player.leaderstats.Gems.Value  
		
	}
	
	
	local success, errormessage = pcall(function()
		SaveSlot:SetAsync(PlayerUserId, SavedData)
	end)
	
	
	
end)

--------------------------------------

This is really wierd, I just used your code and it started working i think it may be roblox servers lagging or something

check a solution then so people with similar if not same issues can look back to it and see what’s the problem

That’d be quite coincidental.

I just realised you were loading the data without having anything to fall back on if the player hadn’t played before.

local DataStoreService = game:GetService("DataStoreService")
local SaveSlot = DataStoreService:GetDataStore("SaveSlotTesting")

local DefaultData = {
	"Level" = 0,
	"Gems" = 0
}


game.Players.PlayerAdded:Connect(function(player)
	
		

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	
	
	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = leaderstats

	
	local Gems = Instance.new("IntValue")
	Gems.Name = "Gems"
	Gems.Parent = leaderstats

	print("instances created")


	
	local PlayerUserId = player.UserId 
	
	       	
	local LoadedSaveData 
	local success, errormessage = pcall(function()
		LoadedSaveData = SaveSlot:GetAsync(PlayerUserId) or DefaultData
	end)
	
	if success then
		print("success")
		if  LoadedSaveData then
			print("loaded data")
			player.leaderstats.Level.Value = LoadedSaveData.LevelSaveData
			player.leaderstats.Gems.Value = LoadedSaveData.GemsSaveData
			print("set data")
			end
		
		
	end
	
	----------------------------------
		

end)



game.Players.PlayerRemoving:Connect(function(player)
	
	local PlayerUserId = player.UserId 
	
	local SavedData = {---
		
		LevelSaveData = player.leaderstats.Level.Value,
		GemsSaveData = player.leaderstats.Gems.Value  
		
	}
	
	
	local success, errormessage = pcall(function()
		SaveSlot:SetAsync(PlayerUserId, SavedData)
	end)
	
	
	
end)

--------------------------------------

Check if the game’s http requests are on.

This cannot happen in any case, since no other games experience this. It could be because of the game’s code or http requests being disabled

if this is the case, don’t you think it’ll happen again, you can’t just brush this off

Datastore service does not require this. You need to enable API services in studio, instead of http requests.