Hello, read the title & the way I tried to do this was:
local function touchingLegs(parts)
print(parts)
if(parts) then
for i, part in ipairs(parts) do
if(part.Name == "Left Leg" or part.Name == "Right Leg") then
return true
else
return false
end
end
end
end
if(not touchingLegs(itemRayResult.Instance:GetTouchingParts()))
--do something
end
but it won’t get no collision parts and legs don’t have collisions so it doesn’t work.
if(not touchingLegs(itemRayResult.Instance:GetTouchingParts()))
--do something
end
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if(not gameProcessedEvent) then
if(input.UserInputType == Enum.UserInputType.MouseButton1) then
local itemRayResult = rayResult(userInputService:GetMouseLocation().X,
userInputService:GetMouseLocation().Y)
if(itemRayResult) then
if(itemRayResult.Instance:FindFirstChild("GrabId")) then
if(not touchingLegs(itemRayResult.Instance:GetTouchingParts())) then
grabId = itemRayResult.Instance.GrabId
game:GetService("ReplicatedStorage").RemoteEvents.Grab:FireServer(grabId, true, itemRayResult.Position)
end
end
end
end
end
end)
Use workspace:GetPartsInPart(itemRayResult.Instance) instead of using GetTouchingParts
workspace:GetPartsInParts is able to detect parts that have CanCollide set to false by default, although you’ll need to pass an OverlapParams with BruteForceAllSlow set to true as a second argument to GetPartsInParts if the parts you’re trying to detect also have CanQuery set to false
On another note, for R15 characters the leg parts are called: LeftFoot, LeftLowerLeg, LeftUpperLeg, RightFoot, RightLowerLeg, RightUpperLeg, if you wish to detect them as well