How to use Workspace:GetPartsInPart
?
Workspace:GetPartsInPart()
is a type of spacial query
returns a table with all objects within a part
pretty self explanatory, use case:
local part0 = workspace.Part
local parts_detected = workspace:GetPartsInPart(part0)
print(parts_detected) --> {...}
GetPartsInPart() has 2 parameters,
the part as 1st parameter, and 2nd
as overlap params, you can learn about them here
Also, here’s the GetPartsInPart() documentation
for better understanding: GetPartsInPart(…)
You can use GetPartsInPart for hitboxes or anything
related to detecting some kind of accurate hitbox
Better example of the usage:
local part0 = workspace.Part
local parts_detected = workspace:GetPartsInPart(part0)
local character = LocalPlayer.Character
print(parts_detected) --> {...}
for _, obj in parts_detected do
if obj:IsDescendantOf(character) then -- the detected part is inside the character
print("I touched this part!")
end
end
Does it basically check if the player is standing on a part or something?
it uses boundary-querying
which relies on a specifix boundary,
not sure if it can detect the player being above a part?
test it and find out, most likely will work
if obj:IsDescendantOf(character) then
How can a part be a descendant of a character?
I tested it and it didn’t print out ‘I touched this part’
any part can be descendant of anything
humanoid root part is a part that is a descendant of the character
left leg, left arm, … are all descendant of the character model
you must be doing something wrong
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.