Problem with the collection service

  1. I wanted to make a collection service for killparts and disappearingparts.

  2. The issue is that its giving me an error on the kill script when I add the disappearing parts scripts but it still works. but I don’t want this error can anyone help?

Error

image

Kill Script
local CollectionService = game:GetService("CollectionService")

local TaggedParts = CollectionService:GetTagged("KillPart")

for _, TaggedPart in pairs(TaggedParts) do
	TaggedPart.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			hit.Parent:WaitForChild("Head"):Destroy()
		end
	end)
end
Disappear Script
local CollectionService = game:GetService("CollectionService")

local TaggedParts = CollectionService:GetTagged("WrongPath")

for _, TaggedPart in pairs(TaggedParts) do
	TaggedPart.Touched:Connect(function(collideOff)
		if collideOff.Parent:FindFirstChild("Humanoid") then
			TaggedPart.CanCollide = false
			wait(6)
			TaggedPart.CanCollide = true
		end
	end)
end
  1. I have looked over the hub and I have not seen any solution.

Thanks. For Helping!

It’s just a warning. To silence it, just change it to :FindFirstChild(‘Head’) or add the timeout argument (:WaitForChild(‘Head’, 5))

Thanks you for your help! Really Appreciated.

1 Like