Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I kill another team if they touch something?

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.