So I have been looking everywhere, tried everything, and my script still doesn't work. Here is my server script in workspace:

local ds = game:GetService("HttpService")
local das = game:GetService("DataStoreService")
local played = das:GetDataStore("plAyED")
local invs = das:GetDataStore("Inventory")
local function load(plr)
	local f = Instance.new("Folder",game.ServerStorage)
	f.Name = tostring(plr.Name)
    local playedbefore = Instance.new("BoolValue",plr)
	playedbefore.Name = "PlayedBefore"
	playedbefore.Value = played:GetAsync(plr.UserId,playedbefore.Value) or false
	wait()
	local inv = {}
	if playedbefore.Value == true then
		print("The player is not new.")
		for i = 500000,0,-1 do
			local s, e = pcall(function()
				inv = {invs:GetAsync(plr.UserId,ds:JSONDecode(inv))}
			end)
			if s then
				print("Loaded Data!")
				i = 0
				break
			end
			if e then
				warn(e)
			end
		end
		wait()
		local num = table.getn(inv)
		if num >= 1 then
			for i, v in pairs(inv) do
				local t = table.unpack(inv,i,i)
				local cl = game.ReplicatedStorage:WaitForChild(t):Clone()
				local cll = game.ReplicatedStorage:WaitForChild(t):Clone()
				cl.Parent = plr.Backpack
				cll.Parent = plr.StarterGear
			end
		end
	else
		inv = {"Sword"}
		wait()
		for i, v in pairs(inv) do
			local t = table.unpack(inv,i,i)
			local cl = game.ReplicatedStorage:WaitForChild(t):Clone()
			local cll = game.ReplicatedStorage:WaitForChild(t):Clone()
			cl.Parent = plr.Backpack
			cll.Parent = plr.StarterGear
		end
	end
end

local function save(plr)
    local inv = {}
	for i, v in pairs(game.ServerStorage:WaitForChild(plr.Name):GetChildren()) do
		table.insert(inv,#inv + 1,v.Value)
		v:Destroy()
	end
	wait()
	for i = 50000,0,-1 do
		local s, e = pcall(function()
			invs:SetAsync(plr.UserId,invs:JSONEncode(inv))
		end)
		if e then
			warn(e)
		else
			break
		end
	end
	if plr:WaitForChild("PlayedBefore").Value == false then
		for i = 50000,0,-1 do
			local s, e = pcall(function()
				played:SetAsync(plr.UserId,true)
			end)
			if e then
				warn(e)
			else
				break
			end
		end
	end
end

game:GetService("Players").PlayerAdded:Connect(function(plr)
   load(plr)
end)

game:GetService("Players").PlayerRemoving:Connect(function(plr)
    save(plr)
end)
game:BindToClose(function()
    for _, client in ipairs(game.Players:GetPlayers()) do
		coroutine.wrap(save)(client)
    end
end)

Here is my local script in StarterGui:

local plr = game.Players.LocalPlayer
local area = plr:WaitForChild("StarterGear")
wait()
if #area:GetChildren() > 0 then
	for i, v in pairs(area:GetChildren()) do
		game.ReplicatedStorage.UpdateInventory:FireServer(v.Name)
	end
end
area.ChildAdded:Connect(function(obj)
	game.ReplicatedStorage.UpdateInventory:FireServer(obj.Name)
end)

Here is my server script in ServerScriptService:

game.ReplicatedStorage:WaitForChild("UpdateInventory").OnServerEvent:Connect(function(plr,tool)
	local f = game.ServerStorage:WaitForChild(plr.Name)
	local st = Instance.new("StringValue",f)
	st.Name = "Item"
	st.Value = tool
end)

I think it loads it correctly but does not save it because it gives me this error: Infinite yield possible on 'ReplicatedStorage:WaitForChild("{[]}")'.

PLEASE CAN SOMEONE HELP