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

Prevent Scripts Picking Teammates for damage?

Asked by 6 years ago

There are two teams labeled Red Team and Blue Team respectively. How would i make this script not hurt anyone on the same team as the one who clicked on it?

player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:connect(function()
    if game.Players.NumPlayers > 0  then
        local player = math.random(1, game.Players.NumPlayers);
        local Players = game.Players:GetPlayers()
        local selected = (Players[player])
        script.Parent.Text = selected.Name
        selected.Character.Humanoid.Health = selected.Character.Humanoid.Health/2
        local torso = selected.Character.Torso
        local i = Instance.new('Fire')
        i.Parent = torso
        i.Color = Color3.new(0, 90, 236)
        i.SecondaryColor = Color3.new(0, 90, 236)
        wait(4)
        i:Destroy()
    end
end)

Answer this question