The Parent property of Model is locked, current parent: NULL, new parent FoodFolder

local plr = game.Players.LocalPlayer
local partCount = math.random(3, 25) -- Adjust the range as per your requirement
local currentPartIndex = 1

local PartsFolder = Instance.new("Folder")
PartsFolder.Name = "FoodFolder"
PartsFolder.Parent = workspace
local amount = 0
local children = script.Stock:GetChildren()
wait(5)

plr.Team.Changed:Connect(function(name)
	print(name)
	if name == "Cashier" then
		print("awdw")
		
	end
end)

local function SpawnNextPart()
	if currentPartIndex > partCount then
		print("Finished")
		amount = 0
		return
	end

	local randomIndex = math.random(1, #children)

	local randomChild = children[randomIndex]
	if randomChild then
		randomChild.Parent = PartsFolder

	end

	print("Randomly selected child:", randomChild.Name)
	for i, v in pairs(script.Stock:GetDescendants()) do
		if v:IsA("MeshPart") or v:IsA("Part") then
			v.Anchored = true
		end
	end
	wait()
	for i, v in pairs(PartsFolder:GetChildren()) do
		if v:FindFirstChild("ClickDetector") then
			
			v.ClickDetector.MouseClick:Connect(function()
				amount += 5
				plr.PlayerGui.SurfaceGui.Frame.Price.Text = "Price: "..amount
				script.Beep:Play()
				v:Destroy()
				print("Part " .. currentPartIndex .. " destroyed.")
				currentPartIndex = currentPartIndex + 1
				SpawnNextPart()
			end)
		end
		
	end
end


game.ReplicatedStorage.JobEvents.Cashier.Client.OnClientEvent:Connect(function()
	if plr.Team.Name == "Cashier" then
		local remoteFunction = game.ReplicatedStorage.JobEvents.Cashier.Join:InvokeServer()
		print(remoteFunction)
		
		for i, v in pairs(workspace.Registers:FindFirstChild(remoteFunction).Jil:GetChildren()) do
			v.CanCollide = true
		end
		
		local model = script.Rig:Clone()
		model.Parent = workspace
		model.Humanoid:MoveTo(workspace.Registers:FindFirstChild(remoteFunction).Point.Position)
		plr.PlayerGui.SurfaceGui.Adornee = workspace.Registers:FindFirstChild(remoteFunction).Model.PrimaryPart
		SpawnNextPart()
		
		
	end
end)

That is an error you get when you try to parent something after :Destroy() was called on it or its parent.

this part of your program probably has the error in it, see if you can arrange the order of operations your code chooses