GetPartsInPart() not detecting characters that havent moved

I’ve been working with GetPartsInPart() for a hitbox for my weapon. It has been going pretty well till i noticed this issue.

GetPartsInPart() doesn’t detect characters that don’t move and it doesnt print anything out in the output. However if they are moving it detects them. I’ve looked around on the forums but haven’t seen a post addressing this issue.

This is the code I’ve been using to get the detection.

connection = rs.Heartbeat:Connect(function()

			local detection = workspace:GetPartsInPart(hitbox, paramas)

			for _, hit in pairs(detection) do

				if hit.Parent and hit.Parent:FindFirstChild("Humanoid") and not table.find(debounce, hit.Parent) then

					table.insert(debounce, hit.Parent)

					print(hit.Parent.Name .. " was hit")


					table.remove(debounce, table.find(debounce, hit.Parent))




npc is clearly in the hitbox but the output prints nothing.

Any help would be appreciated!


Have you given the rig an idle animation?

Yeah I have given the rig idle animation.

Is it something to do with the extra check?
try printing this:

    print(hit.Parent, "  ", hit.Parent:FindFirstChild("Humanoid"), "  ", table:find(debounce), "  ", table.find(hit.Parent))  
    -- Above line may need to be changed to get the actual items, maybe try Humanoid.Name or something similar
	if hit.Parent and hit.Parent:FindFirstChild("Humanoid") and not table.find(debounce, hit.Parent) then

Maybe you can try using getpartsboundsinbox? Just a wild guess.

1 Like

No I’ve tried it without the check and it still doesn’t detect for some reason

But if you troubleshoot with the print I suggested you can see what causes the if check to fail and go from there.

So I’ve played around with it more and I got curious to see what would happen if it didn’t have any checks and surprisingly didn’t print anything. I’m genuinely so confused.

1 Like

local detection = workspace:GetPartsInPart(hitbox, paramas)
Is hitbox a direct child of the workspace?

hitbox is in a folder in the workspace called Debris

The hierarchy is workspace.Debris

you should task.spawn the wait so that you dont slow down the loop. Because its causing the loop to wait for .1 seconds and each frame is done in milliseconds, then the wait wont be finished, and no parts is looped in

The thing is even without the wait it doesn’t print anything out. Its like nothing is touching it.

ok so try printing detection, and you dont really need to check if hit.Parent exists because there will always be a parent. Tell us what you see because i dont really understand whats not hapenning

1 Like

I’ve realized that awhile ago and removed it but it isn’t detecting anything.

You might be using include over exclude for the OverlapParams. Also remove the task.wait(), it’s not good to yield Heartbeat frames like that, just use an os.clock() debounce.

local lastTime = 0
     local timeNow = os.clock()
     if timeNow < lastTime then return end; lastTime = timeNow + 0.1

    -- code

Try printing the table detection. Try ipairs or nothing over pairs because the latter is meant for Dictionary not array and while it might work it can lead to inconsistent results.

-- use this over ipairs and pairs
for _, hit in detection do


Make sure the hitbox has CanQuery to true, disable CanTouch just to see what happens.

1 Like

I’ll try this out! I will tell you how it works out!

I forgotten to mention that the hitbox.Anchored = false and connected by a WeldConstraint

bump im still trying to find out why it isnt working

Like the other guy said is canquery set to true?

1 Like

I’m not too familiar with it, but doesn’t this line only look for hitbox directly in the workspace, not in a subfolder? Shouldn’t you reference the folder like this:
local detection = workspace.Debris:GetPartsInPart(hitbox, paramas)