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

How can I modify It so whenever your on a team, you cannot damage your team mates?

Asked by 2 years ago

As the name says, I was wondering how I can modify the script so It won't damages players If there one your team (Btw the gun name Is SI2010 (The SI means "Skill Issue"))

Script:

local tool = script.Parent

---Sounds---
local ShotgunSound = tool.FireSound

---Animation---
local Shot = tool.Shot

---Other stuff---
local debounce = false

tool.Activated:Connect(function()
    if not debounce then
        debounce = true
        ShotgunSound:Play()
        local Char = tool.Parent
        local Hum = Char.Humanoid

        local AnimationTrack = Hum:LoadAnimation(Shot)
        AnimationTrack:Play()
        local MeshPartPojectile = Instance.new("MeshPart")
        local VectorForce = Instance.new("VectorForce")
        local Attachment = Instance.new("Attachment")

        MeshPartPojectile.Parent = game.Workspace
        MeshPartPojectile.Size = Vector3.new(1,1,1)
        MeshPartPojectile.TextureID = "http://www.roblox.com/asset/?id=5694989372"
        MeshPartPojectile.Position = tool.Handle.Position
        MeshPartPojectile.Orientation = tool.Handle.Orientation
        VectorForce.Parent = MeshPartPojectile
        Attachment.Parent = MeshPartPojectile
        VectorForce.Attachment0 = Attachment
        VectorForce.Force = Vector3.new(0,300,-6000)
        MeshPartPojectile.Touched:Connect(function(hit)
            local humanoid = hit.Parent:WaitForChild("Humanoid")
            if humanoid then
                humanoid:TakeDamage(10)
                local UNDERTALE = Instance.new("Sound")

                UNDERTALE.Parent = humanoid.Parent.Torso
                UNDERTALE.Volume = 10
                UNDERTALE.SoundId = "rbxassetid://406913243"
                UNDERTALE:Play()
                MeshPartPojectile:Destroy()
                game:GetService("Debris"):AddItem(UNDERTALE,0.5)
            end
        end)
        game:GetService("Debris"):AddItem(MeshPartPojectile,5)
        game:GetService("Debris"):AddItem(VectorForce,5)
        game:GetService("Debris"):AddItem(Attachment,5)
        wait(1)
        debounce = false
    end
end)

1 answer

Log in to vote
0
Answered by 2 years ago

You can use player.TeamColor to check their teams.

Use something like this before damaging them to stop the script from taking their health away.

if (player.TeamColor == otherplayer.TeamColor) then
print('same team')
return
end
Ad

Answer this question