I am attempting to use the workspace:GetPartsInPart function to detect whether a player is currently standing within a hitbox region. This has successfully yielded me a table of different parts, but I am having an issue checking whether the hitbox part is within that list (the getpartsinpart function is done relative to the player’s humanoidrootpart). Listed below is my current code:
while wait(.1) do
local touchingParts = workspace:GetPartsInPart(humRoot)
print(touchingParts)
print(table.find(touchingParts, "InteriorHitbox"))
end
HumRoot is a defined variable, the table is outputting correctly. My issue is with this line:
This properly prints “nil” when interiorHitbox is not touched, but continues to print “nil” even when it is being touched. I believe it may have something to do with interiorHitbox being listed as an object and not a text string on the list. However, I have no clue how I would go about fixing that.
Overall, I just need to be able to determine if a certain part is present within a workspace:GetPartsInPart list.
If you need any addition information, let me know. I will likely be actively monitoring this post for the next 15 minutes and will periodically check after that. Any and all help or suggestions are appreciated.
To put in simply, it’s printing nil because “InteriorHitbox” is not inside the table provided by :GetPartsInPart. Are you sure that the humRoot instance is inside of your InteriorHitbox? Try instead looping through and printing every part that is inside the table using a for loop. I’m also not too familiar with GetPartsInPart and what it requires for it to detect an object
while wait(.1) do
local touchingParts = workspace:GetPartsInPart(humRoot)
print(touchingParts)
for i,v in pairs(touchingParts) do
print(v)
end
end
The entire table prints correctly, and it does list the InteriorHitbox within it. I assume you meant that the issue is with the instance not being in the table at all?
that sounds like a pain but I probably will just have to do that. Thanks for letting me know. I assume its just a for i, v in pairs function that checks the name of each part in the table.