I am making a script that detect player inside a part and I want to reduce the size of array from GetPartsInPart function because I will infinitely iterate through the array and in case of many players are inside the area at once.
I used FilterDescendantsInstance but I can’t directly assign a table of body part’s name into it or using enum because it will cause “Unable to cast value to Objects” error.
The problem is it return only part from player the script above detect first, not any player who are inside the part.
Are there any ways to put name of character’s part to filter or any functions that can do this kind of stuff or name of topic that relate to this issue so I can learn.
Oof, I realize that line 2 and 3 run regardless of the order of code, so I just need to make a list to contain body part of every character that is added and constantly update filter.
you could just get all the characters in game and add those to array and pass it to it then it will consider any characters body parts/descendants
maybe like this
local Characters = {}
for _, player in ipairs(game.Players:GetPlayers()) do
table.insert(Characters, player.Character)
end
ovl.FilterDescendantsInstances = Characters
should work now had to fix Players had typo
and i will say roblox did something in an update today to GetPartsInPart and even when sitting on a part it may not show its touching it
In this case, The GetPartsInPart will detect other parts that are in character model too(left/right hand arm and leg, head, hat, etc) so I think it is not the best way to get smallest array of GetPartsInPart.
and thank you for telling me about the update I will look into it, thank you for your time.