I need help with my datastore script

So I’m very new to datastore scripts and I know bassicaly nothing.

My issue is that every time is stop the game I get a warning:
DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key =

local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local items = replicatedStorage.Items

local dataStoreService = game:GetService("DataStoreService")
local dataStore = dataStoreService:GetDataStore("InventoryData")


local tries = 3
local dataloaded = nil

local function serialize(plr)
	if dataloaded then
		local key = plr.UserId
		local count = 0

		local data = {}

		for i, v in ipairs(plr.Items:GetChildren()) do
			if v and v:IsA("NumberValue") then
				data[v.Name] = v.Value
			end
			
		for i, v in ipairs(plr.Items.Ores:GetChildren()) do
		if v and v:IsA("NumberValue") then
				data[v.Name] = v.Value
				end
				
		for i, v in ipairs(plr.Items.ItemLevels:GetChildren()) do
			if v and v:IsA("NumberValue") then
				data[v.Name] = v.Value
						
			end
				end
				end
end
		local success, err

		repeat
			success, err = pcall(function()
				dataStore:SetAsync(key, data)
			end)

			count = count + 1
		until count >= tries or success

		if not success then
			warn("Data could not be set." .. tostring(err))

			return
		end
	else
		warn("Data has not been loaded. Do not attempt to set data when it has not been loaded.")

		return
	end
end
local function deserialize(plr)
	local key = plr.UserId
	local count = 0

	local data

	local success, err

	repeat
		success, err = pcall(function()
			data = dataStore:GetAsync(key)
		end)

		count = count + 1
	until count >= tries or success

	if not success then
		warn("Failed to read data." .. tostring(err))

		plr:Kick("Failed to read data. Please rejoin the game.")

		return
	end

	if data then
		dataloaded = true

		return data
	else
		dataloaded = true

	end
end

local function createInventory(plr)
	local dataFolder = Instance.new("Folder", plr)
	dataFolder.Name = "Items"

	local item = Instance.new('Folder', dataFolder)
	item.Name = 'Ores'
	
	local itemlevels = Instance.new('Folder', dataFolder)
	itemlevels.Name = 'ItemLevels'

	local data = deserialize(plr)

	if data then
		for i, v in ipairs(items:GetChildren()) do
			local int = Instance.new('NumberValue', dataFolder)
			int.Name = v.Name
			int.Value = data[v.Name]

			end	
		for i, v in ipairs(replicatedStorage.Ores:GetChildren()) do	
				local int = Instance.new('NumberValue', item)
				int.Name = v.Name
			int.Value = data[v.Name]
			end
		for i, v in ipairs(replicatedStorage.ItemLevels:GetChildren()) do	
				local int = Instance.new('NumberValue', itemlevels)
				int.Name = v.Name
				int.Value = data[v.Name]
				
		end
		plr.Items.BagCost.Value = 50
		plr.Items.maxBag.Value = 50
		plr.Items.BagLevel.Value = 1
		plr.Items.ItemLevels.PickaxeDmgLVL.Value = 1
		plr.Items.ItemLevels.PickaxeLevel.Value = 1
		plr.Items.ItemLevels.PickaxeSpeed.Value = 1
		plr.Items.Stage.Value = 1
		plr.Items.CurrentOre.Value = 8
		end    
	end

players.PlayerAdded:Connect(createInventory)
players.PlayerRemoving:Connect(serialize)

game:BindToClose(function()
	for i, plr in ipairs(players:GetPlayers()) do
		serialize(plr)
	end
end)

you are sending information too quickly. Try sending less requests at a time. You could add a wait() before each request.

Uhh, couldyou highlight the part of the script where that is? I’m not really sure where it is.

repeat
			success, err = pcall(function()
				dataStore:SetAsync(key, data)
			end)

			count = count + 1
		until count >= tries or success

Well now I put a bunch of waits here but it is still giving the same error.

		repeat
			wait(5)
			success, err = pcall(function()
				wait(5)
				dataStore:SetAsync(key, data)
			end)

			count = count + 1
			wait(5)
		until count >= tries or success

DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key =