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
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 then local Humanoid = Rig:FindFirstChildOfClass("Humanoid") if Humanoid ~= nil then Humanoid:TakeDamage(Damage) end end end end