Hello, I was using raycasting to try and make a simple gun tool, I wanted to, upon the ray casting check the children of the model or part, if it contains a “Humanoid” and when it does detect it subtracts 10 hp from the Humanoid, but whenever It hits the player character, despite it only checking for “Humanoid” objects it tries to take away the Health from a Body Part.
also sorry if some of this doesn’t make sense I’m pretty tired and barely function.
if Resutlt then
print("RayCasted")
local hitObj = Resutlt.Instance
for i, child in ipairs(hitObj.Parent:GetChildren()) do
if child:IsA("Humanoid") then
print("humanoid detected",child:IsA("Humanoid"),child)
child.Health = hitObj.Health - 10
break
end
end
end