What am I doing wrong(getPartsinPart)?

local LocalPlayer = game.Players.LocalPlayer

local HomeHitbox = workspace.Hitbox
local parts_detected = workspace:GetPartsInPart(HomeHitbox)
local hrp = LocalPlayer.Character:WaitForChild(“HumanoidRootPart”)

while a == true do

print(parts_detected)

for i, obj in pairs(parts_detected) do
if obj:IsDescendantOf(hrp) then
print(“I touched this part!”)
end
end

end

Follow the template that you get when making a post if you are incapable of making your own.

Template:
You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Are you getting any prints in the Output window?

Is the game freezing because you don’t have a task.wait() in the while true do loop?

I have a task wait in my script just didnt show it my problem is that I wont get the “I touched this part” print output even though i am touching the hitbox

Do you get the parts_detected output?

yes I do and its showing every other part which is in this hitbox