Collecting Dropped Flag issue

I’m having trouble working out exactly what is going on here. I have parts that drop when the player dies that correspond to the opposing teams flag as shown here.

image
image



local function overLapParts(character)
	print("OverlapParams Initiated")
	local rootPart = character:FindFirstChild("HumanoidRootPart")

	local params = OverlapParams.new()
	params.FilterType = Enum.RaycastFilterType.Include
	params.FilterDescendantsInstances = {droppedFlagsFolder}

	local parts = workspace:GetPartsInPart(rootPart, params)

	for _, part in pairs(parts) do
		if CollectionService:GetTagged(part, "Flag") then
			print("Part name found and is called: ", part.Name)
			return part
		end
	end
end

local function onFlagTouched(otherPart: BasePart)
	local character = otherPart.Parent
	
	if character and character:FindFirstChild("Humanoid") then
		local player = Players:GetPlayerFromCharacter(character)

		if player and character.Humanoid.Health > 0 then
			if playersTouching[player.Name]then
				return
			end
			playersTouching[player.Name] = true
			print(player.Name, "touched the part")
			local flagPart = overLapParts(character)
			print("flagPart name returned is: ", flagPart.Name)
			
			if flagPart then
				local flagType = flagPart:GetAttribute("FlagType")
				if flagType == "BlueFlag" then
					blueFlagCollected(player, flagPart)
				elseif flagType == "RedFlag" then
					redFlagCollected(player, flagPart)
				end
			end
			task.wait()
			playersTouching[player.Name] = nil
		end
	end
end

Any idea what’s causing it?
The flags are indeed being parented to the droppedFlagsFolder and they are called “Flag” with an attribute inside with the FlagType = “BlueFlag” or “RedFlag”.
I also have a series of attributes for checks also.
image

Whats messing up here is before your for loop with the collectionservice. The script initiates the overlapparams but never prints "Part name found and is called: ". This is because of the “parts” variable not getting any parts from the humanoidRootPart. Could it be that youre parenting the flag to the “DroppedFlags” Folder but not the humanoidrootpart,

Well when the player dies, rather than have all their teammates have to go all the way back to the other teams base to get the flag again I just created a part and put a billboard gui in it to simulate a dropped flag that another player can then pick up or reset (like world of warcraft battleground).

I added a touch event to the part so it could be collected and since the parts will either be in the folder if the flag was dropped or not if another player has picked it up, I added tags to make sure the collection service could collect any flag with the tag “Flag” on it. It’s extremely difficult to get the touchPart of a touched event within the touch event function so I opted for a spacial query instead, attempting to find the part the player has touched by limiting the query to only the parts in the folder and the root part of the player…or so I thought.

Do you have a solution?