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

How do I kill another team if they touch something?

Asked by 10 years ago

For example:

[[I am another team member trying to access another person base VIA door. But it kills them]]

How/what script will I need for it to work?

It only kills that person from that specific team.

1 answer

Log in to vote
0
Answered by
Nifer2 174
10 years ago

Lets assume the teams are called "Red" and "Blue".

door = script.Parent -- Assume this is the door/brick's location.
players = game.Players:GetChildren()

function onTouch(part)
    for i = 1, #players do
        if part:IsDescendantOf(players[i].Character) then
            return players[i]
end

door.Touched:connect(function(part)
    local player = onTouch(part)
    if not player then
        return
    end

    local access = player.Team == "Red" -- Lets the Red team go through the door.

    if access then
        door.Transparency = 0.5
        door.CanCollide = true
        wait(0.5)
        door.Transparency = 0
        door.CanCollide = false
    end

    if not access then
        player.Character.Humanoid.Health = 0
    end

end)

The function OnTouch part of the script checks for players and the door.Touched:connect() part activates once the door has been touched. If the player is in the Red team then the door lets them through. If they aren't then the door kills them.

Ad

Answer this question