Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Bullet doesn't always register damage?

Asked by 5 years ago
Edited 5 years ago

I'm attempting to make a gun, everything works perfectly besides the damage. The damage will only sometimes work, and I can't find what is wrong. Sorry if my indentation isn't good. Here is the snippet with the damage:

bullet.Touched:Connect(function(hitted)
    if hitted.Parent.Name ~= Player and hitted.Name ~= "Handle" and hitted.Parent:FindFirstChild("Humanoid") ~= nil then
    if hitted.Name == "UpperTorso" or hitted.Name == "LowerTorso" then
        hitted.Parent.Humanoid:TakeDamage(Damage)
    elseif hitted.Name == "RightUpperArm" or hitted.Name == "RightLowerArm" or hitted.Name == "RightHand" or "LeftUpperArm" or hitted.Name == "LeftLowerArm" or hitted.Name == "LeftHand" then
        hitted.Parent.Humanoid:TakeDamage(Damage - 10)
    elseif hitted.Name == "RightUpperLeg" or hitted.Name == "RightLowerLeg" or hitted.Name == "RightFoot" or "LeftUpperLeg" or hitted.Name == "LeftLowerLeg" or hitted.Name == "LeftFoot" then
        hitted.Parent.Humanoid:TakeDamage(Damage - 5)
    elseif hitted.Name == "Head" or hitted:IsA("Accessory") then
        for i = HeadshotSurival,20 do
            if i <= HeadshotSurival then
            hitted.Parent.Humanoid:TakeDamage(HeadshotDamage)
            else hitted.Parent.Humanoid:TakeDamage(hitted.Parent.Humanoid.Health)
        end
        end
    end
    end
end)

Each limb has a different amount of damage, and the headshot has a change to survive. (This is in a serverscript and is fired by a remotevent)

0
As SomeDumbNinja said, use raycasting, It should make it work. hotpot888 2 — 5y
0
This gun doesn't use raycasting CaptainAlien132 225 — 5y

Answer this question