Whenever a player touches a part that the script is parented to the player would take damage. But for some reason npcs do not take damage from it. How would I fix this?
local Players = game:GetService("Players")
local Debounce = .3
local Damage = 5
while wait(Debounce) do
local Connection = script.Parent.Touched:Connect(function() end)
for _,Object in pairs(script.Parent:GetTouchingParts()) do
Connection:Disconnect()
local Rig = Object:FindFirstAncestorWhichIsA("Model")
if Rig ~= nil and Players:GetPlayerFromCharacter(Rig) ~= nil then
local Humanoid = Rig:FindFirstChildOfClass("Humanoid")
if Humanoid ~= nil then
Humanoid:TakeDamage(Damage)
end
end
end
end

3 comments
You are checking on line 9 if the model belongs to a player. Perhaps remove that check.
That worked! Thanks.
true, it is the answer