Why do I keep getting this output every few minutes?

Hello! I am getting this output every few minutes, which It wasn’t doing it before. Why is it doing it now? I assume its for my leaderstats DataStore


This also includes being inside main game

Outputs ^

And here is my script

local ds = game:GetService("DataStoreService"):GetDataStore("savedata")
game.Players.PlayerAdded:Connect(function(plr)
	wait()
	local plrkey = "id_"..plr.userId
	local save1 = plr.leaderstats.Coins
	local save2 = plr.leaderstats.Money
	local save3 = plr.leaderstats.Gems
	local save4 = plr.leaderstats.EggsOpened
	
	local GetSaved = ds:GetAsync(plrkey)
	if GetSaved then
		save1.Value = GetSaved[1]
		save2.Value = GetSaved[2]
		save3.Value = GetSaved[3]
		save4.Value = GetSaved[4]
	else
		local NumberforSaving = {save1.Value, save2.Value, save3.Value, save4.Value}
		ds:GetAsync(plrkey, NumberforSaving)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	ds:SetAsync("id_"..plr.userId, {plr.leaderstats.Coins.Value, plr.leaderstats.Money.Value, plr.leaderstats.Gems.Value, plr.leaderstats.EggsOpened.Value})
end)

Any help will be appreciated!

This is not because of your leaderstats. If you look at the key given in the warning, it just is “1180451546” not “id_”…plr.UserId which would be “id_1180451546”.

Which datastores do you have that try to update the data every few minutes?

Possibly the Door Datastore for all the purchasable Doors? But I’ve had this error sometime I think long ago when I started making the game? But I’m not sure…

Could be :man_shrugging:
Could you show the script for that?

Just know that if you are getting that warning every few minutes then a data store is trying to save data every few minutes.

local ds = game:GetService("DataStoreService")

	game.Players.PlayerAdded:Connect(function(player)
		
		local f = Instance.new("Folder",player)
		f.Name = "Doors"
		
		for i,v in pairs(game.Workspace.Doors:GetChildren()) do
		local DoorData = ds:GetDataStore(v.Name)
		local pDD = DoorData:GetAsync(player.UserId) or false
		local b = Instance.new("BoolValue",f)
		b.Name = v.Name
		b.Value = pDD
		
		b.Changed:connect(function(v)
			DoorData:SetAsync(player.UserId,v)
		end)
	end
end)
	
game.ReplicatedStorage.BuyDoor.OnServerEvent:Connect(function(player,door,cost)
	local LocalDoor = game.Workspace.DoorsKeys[door]
	if player:WaitForChild(LocalDoor:FindFirstChildOfClass("Folder").Name)[LocalDoor:FindFirstChildOfClass("Folder").Currency.Value].Value >= cost then
		player:WaitForChild(LocalDoor:FindFirstChildOfClass("Folder").Name)[LocalDoor:FindFirstChildOfClass("Folder").Currency.Value].Value -= cost
		player.Doors:WaitForChild(door).Value = true
	end
end)

That is wayyyy too frequent you typically want to avoid saving with intervals no less than 30 seconds.

You could add a debounce :man_shrugging:

So I’m assuming this is the script. BuyDoor is being fired a lot, correct? If not, then this is not the script.

There are many things wrong with the way you are trying to save data. Doing :SetAsync() every. single. time. a value is just changed is bad. Having a datastore for each and every single door is bad. You want to just store all of this in a table. Like this:

local ds = game:GetService("DataStoreService"):GetDataStore("DoorsDataStore")
--a bunch of code
game.Players.PlayerRemoving:Connect(function(plr)
    local data = {}
    for i, v in pairs(plr.Doors:GetChildren()) do
        data[v.Name] = v.Value
    end
    ds:SetAsync(plr.UserId, data)
end)

then when you get the data go through the table in a loop and set the values.

Like that?

local ds = game:GetService("DataStoreService")

	game.Players.PlayerAdded:Connect(function(player)
		
		local f = Instance.new("Folder",player)
		f.Name = "Doors"
		
		for i,v in pairs(game.Workspace.Doors:GetChildren()) do
		local DoorData = ds:GetDataStore(v.Name)
		local pDD = DoorData:GetAsync(player.UserId) or false
		local b = Instance.new("BoolValue",f)
		b.Name = v.Name
		b.Value = pDD
		
		b.Changed:connect(function(v)
			DoorData:SetAsync(player.UserId,v)
			
			debounce()
		end)
	end
end)
	
game.ReplicatedStorage.BuyDoor.OnServerEvent:Connect(function(player,door,cost)
	local LocalDoor = game.Workspace.DoorsKeys[door]
	if player:WaitForChild(LocalDoor:FindFirstChildOfClass("Folder").Name)[LocalDoor:FindFirstChildOfClass("Folder").Currency.Value].Value >= cost then
		player:WaitForChild(LocalDoor:FindFirstChildOfClass("Folder").Name)[LocalDoor:FindFirstChildOfClass("Folder").Currency.Value].Value -= cost
		player.Doors:WaitForChild(door).Value = true
	end
end)

I am not that great at coding so it doesn’t make much sense. I got this off a tutorial

I didn’t read into your script but looking further into I realized @IAmPinleon’s points are valid you should try to do what they recommended. You currently aren’t fully utilizing your data store capacity and capabilities. If you continue with what your currently doing it wont solve the problem

image
So I removed the Door DataStore and it seemed to still do it… Is it my Leaderstat Data?