Im trying to detect humanoids and subtract health from them but it can detect multiple children of the model and I don’t know how to make sure it finds the player’s model and then the Humanoid within it
this is the code
tool = script.Parent
boomsize = 6
boommax = 150
tool.Activated:Connect(function()
local grenade = game.ReplicatedStorage.grenade:Clone()
grenade.Position = tool.boom.Position
grenade.Orientation = tool.boom.Orientation
grenade.Parent = workspace
wait(.3)
grenade.VectorForce:Destroy()
wait(.3)
grenade.Touched:Connect(function()
local kablooey = Instance.new("Part")
kablooey.Shape = Enum.PartType.Ball
kablooey.CanCollide = false
kablooey.Anchored = true
kablooey.Size = Vector3.new(boomsize,boomsize,boomsize)
kablooey.Position = grenade.Position
kablooey.Parent = workspace
--this is the problematic part
kablooey.Touched:Connect(function(targ)
print(targ)
if targ.Parent:FindFirstChild("Humanoid") then
if targ:IsA("Humanoid") then
targ.Humanoid.Health -=boommax
end
end
end)
grenade:Destroy()
end
)
end)
it detects handles of accessories and body parts so i must be able to find the player model and then the humanoid