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.
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.