Pellet not inputting damage

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
2 Likes

What is the hit? If hit is a body part, then you should try this:

local Humanoid = Hit.Parent:FindFirstChildOfClass("Humanoid")
1 Like

that doesnt change anything rather than make it look like a begineer scripting

bump, still finding a solution. please help

You should be doing:

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.

1 Like

? He’s correct though. Parts are not descendants of the humanoid, but the character.

1 Like

i already solved it, turns out i forgot how i used modules to damage lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.