function BufferCreator.CreateServerBuffer(z,S)local m=Instance.new("\070\111\108\100\101\114")m.Name=S m.Parent=Tool local r=CreateBuffer(m)local Y function r.AddItem(z,S)S.Parent=m local r=S:IsA("\066\097\115\101\080\097\114\116")and S or S:FindFirstChildWhichIsA("\066\097\115\101\080\097\114\116",true)if r then local S=Vector3.new(math.random(-1000,1000),100000,math.random(-1000,1000))r.CFrame=CFrame.new(S)local z=Instance.new("\066\111\100\121\080\111\115\105\116\105\111\110")z.Position=S z.MaxForce=Vector3.new(math.huge,math.huge,math.huge)z.Name="\066\117\102\102\101\114\080\111\115\105\116\105\111\110\076\111\099\107"z.Parent=r if r:IsDescendantOf(game.Workspace)and(not r.Anchored and Y)then r:SetNetworkOwner(Y)end end end function r.SetCurrentPlayer(z,S)Y=S for z,m in pairs(m:GetChildren())do local r=m:IsA("\066\097\115\101\080\097\114\116")and m or m:FindFirstChildWhichIsA("\066\097\115\101\080\097\114\116",true)if r and(r:IsDescendantOf(game.Workspace)and(not r.Anchored and Y))then r:SetNetworkOwner(S)end end end return r end
--Creates a server-side buffer. Inherits the base buffer class.
function BufferCreator:CreateServerBuffer(BufferName)
	local BufferFolder = Instance.new("Folder")
	BufferFolder.Name = BufferName
	BufferFolder.Parent = Tool

	local Buffer = CreateBuffer(BufferFolder)
	local Player

	--Adds an item to the buffer.
	function Buffer:AddItem(NewItem)
		NewItem.Parent = BufferFolder

		local Part = (NewItem:IsA("BasePart") and NewItem) or NewItem:FindFirstChildWhichIsA("BasePart", true)
		if Part then
			--Add a position lock.
			local HoldPos = Vector3.new(math.random(-1000, 1000), 100000, math.random(-1000, 1000))
			Part.CFrame = CFrame.new(HoldPos)
			local PositionLock = Instance.new("BodyPosition")
			PositionLock.Position = HoldPos
			PositionLock.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			PositionLock.Name = "BufferPositionLock"
			PositionLock.Parent = Part

			--Set the network ownership to the client so it can control physics.
			if Part:IsDescendantOf(game.Workspace) and not Part.Anchored and Player then
				Part:SetNetworkOwner(Player)
			end
		end
	end

	--Sets the network ownership of the buffer.
	function Buffer:SetCurrentPlayer(NewPlayer)
		Player = NewPlayer

		for _, Item in pairs(BufferFolder:GetChildren()) do
			local Part = (Item:IsA("BasePart") and Item) or Item:FindFirstChildWhichIsA("BasePart", true)

			if Part and Part:IsDescendantOf(game.Workspace) and not Part.Anchored and Player then
				Part:SetNetworkOwner(NewPlayer)
			end
		end
	end

	--Return the buffer class.
	return Buffer
end
