when the npc fires a pellet and it hits a humanoid it doesnt damage
i checked with prints and it was weird
local Connection
Connection = Pellet.Touched:Connect(function(Hit)
if not Hit:IsDescendantOf(Char) then
local EnemyFolder
if Enemy then EnemyFolder = workspace:FindFirstChild("Friendly_Entities") else EnemyFolder = workspace:FindFirstChild("Enemy_Entities") end
if EnemyFolder and Hit:IsDescendantOf(EnemyFolder) then
local Humanoid = Hit:FindFirstAncestorOfClass("Humanoid")
if Humanoid then Module:Damage(Char,Humanoid,Damage) end
end
end
Connection:Disconnect()
end)
end
local Model = Hit:FindFirstAncestorWhichIsA("Model")
local Humanoid = Model and Model:FindFirstChildWhichIsA("Humanoid")
if Humanoid then
Module:Damage(Char, Humanoid, Damage)
end
… because, your code currently assumes that the Hit part is a descendant of the Humanoid. This is why nothing is working. If you’re looking for a body part, it will be under a Model, not under a Humanoid.