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

Anti-Team killing section help?

Asked by 6 years ago

I'm trying to convert this section into an Anti-TK one that works in FE. I'd like the script to not apply damage to teammates but to players that aren't in the same team. If anyone could help me make this work, I'd be glad.

Original section

    while PierceAvailable >= 0 do
        local Hit,EndPos = RayCast(Start,Direction,5000,Character)
        if not Module.ExplosiveEnabled then
            if Hit and Hit.Parent then
                local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
                local TargetTorso = Hit.Parent:FindFirstChild("Torso")
                --local TargetTEAM = Hit.Parent:FindFirstChild("TEAM")
                if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
                    --if TargetTEAM and TargetTEAM.Value ~= TEAM.Value then
                        InflictTarget:FireServer(TargetHumanoid,
                                                TargetTorso,
                                                (Hit.Name == "Head" and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage,
                                                Direction,
                                                Module.Knockback,
                                                Module.Lifesteal,
                                                Module.FlamingBullet)
                        PiercedHumanoid[TargetHumanoid] = true
                    --end
                else
                    PierceAvailable = 0
                end
            end

Attempted edit

    while PierceAvailable >= 0 do
        local Hit,EndPos = RayCast(Start,Direction,5000,Character)
        if not Module.ExplosiveEnabled then
            if Hit and Hit.Parent then
                local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
                local TargetTorso = Hit.Parent:FindFirstChild("Torso")
                --local TargetTEAM = Hit.Parent:FindFirstChild("TEAM")
                if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso and Player.TeamColor == "Bright red" then
                    --if TargetTEAM and TargetTEAM.Value ~= TEAM.Value then

                elseif TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
                        InflictTarget:FireServer(TargetHumanoid,
                                                TargetTorso,
                                                (Hit.Name == "Head" and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage,
                                                Direction,
                                                Module.Knockback,
                                                Module.Lifesteal,
                                                Module.FlamingBullet)
                        PiercedHumanoid[TargetHumanoid] = true
                    --end
                else
                    PierceAvailable = 0
                end
            end

1 answer

Log in to vote
0
Answered by 6 years ago
if Hit and Hit.Parent then
    local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
    local TargetTorso = Hit.Parent:FindFirstChild("Torso")
    if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
        -- Get the hit player
        local hitPlayer = game.Players:GetPlayerFromCharacter(TargetHumanoid.Parent)
        -- Check if the local player and the hit player are on different teams. If so, do damage
        if hitPlayer and game.Players.LocalPlayer.Team ~= hitPlayer.Team then
            -- Damage code here
        end
    end
end
0
I love you. Aryosis 3 — 6y
Ad

Answer this question