I’m making a grab move in my game currently, and I want to check if nothing was hit.
Im using GetPartsInPart, my character is excluded from the list. If anymore info is required lmk.
I’m making a grab move in my game currently, and I want to check if nothing was hit.
Im using GetPartsInPart, my character is excluded from the list. If anymore info is required lmk.
GetPartsinPart responds with an array of parts within a given part. To check if the array is empty, you can query the list like this:
local array = workspace:GetPartsInPart(part, overlapParams)
if #array == 0 then
print("no parts touching")
end
In your instance, if you want to check if a humanoid was hit versus not hit, the script would look something like this:
local array = workspace:GetPartsInPart(part, overlapParams)
if #array ~= 0 then
for i,v in array do
local hum = v.Parent:FindFirstChild("Humanoid")
if hum then
print("Player detected")
else
print("No Player detected")
end
end
end