basically im trying to change the “Red hyperlaser” roblox gear into not instakilling and instead just doing damage to the npc being touched aand i ran into this issue: when the projectile hits the torso, instead of doing damage once, it damages the humanoid twice. i can see that it is because the projectile hit both the humanoidrootpart and the torso, so how would i go about making it only damage a certain character once, still being able to “penetrate” them?
heres the code, if you need any additional context just respond to this post
function Touched(Projectile, Hit)
if not Hit or not Hit.Parent then
return
end
local character, humanoid = FindCharacterAncestor(Hit)
if character and humanoid and character ~= Character and game.Players:GetPlayerFromCharacter(character) == nil then
local ForceFieldExists = false
for i, v in pairs(character:GetChildren()) do
if v:IsA("ForceField") then
ForceFieldExists = true
end
end
if not ForceFieldExists then
if Projectile then
humanoid:TakeDamage(Tool.Damage.Value)
Projectile:Destroy()
local HitFadeSound = Projectile:FindFirstChild(Sounds.HitFade.Name)
local torso = humanoid.Torso
if HitFadeSound and torso then
HitFadeSound.Parent = torso
HitFadeSound:Play()
end
end
if humanoid.Health <= 0 then
Dematerialize(character, humanoid, Hit)
end
end
if Projectile and Projectile.Parent then
Projectile:Destroy()
end
end