GetTouchingParts() method isn't working?

Hello, my my detectTouch() function runs but the for loop with the Hitbox’s GetTouchingParts() method isn’t running. Here’s the code I’m using (example, Check 1 is printed but Check 2 isn’t.):

local function detectTouch()
        print("Check 1")
		for _, part in pairs(Hitbox:GetTouchingParts()) do
            print("Check 2")
			if part:IsA("BasePart") and part.Parent:IsA("Model") then
				local Enemy = part.Parent
				local EHumanoid = Enemy:FindFirstChildOfClass("Humanoid")
				local EHumRP = Enemy:FindFirstChild("HumanoidRootPart")
				if Enemy ~= Character and EHumanoid and EHumRP and EHumanoid.Health ~= 0 then
                    Hitbox:Destroy()
                    break
				end	
			end
		end
	end
	
	while Hitbox.Parent do
		task.wait()
		detectTouch()
	end

That means there are no touching parts. GetTouchingParts rarely work as intended for me, so I usually just do Workspace:GetPartsInPart(Part, OverlapParams).

GetTouchingParts() may not work in local scripts (if i’m not mistaken), try using it in a server script

I spawn the hitbox on where an enemy is (And it’s on the server @XxGrantyAutoxX) so that’s why I’m wondering why there’s a problem like this. GetTouchingParts has worked for me before…

It doesn’t usually work for me, try switching to Workspace:GetPartsInPart() and see if that solves it.

Thanks for your contributions, guys, I found one that worked best for me :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.