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 everyone inside of a specific team?

I am trying to kill everyone inside of a specific team once a button is pressed. I already dealt with connecting a remoteEvent to when a button is pressed, so I am able to put this on a normal script.

This is my code right now:

local seconds = game.ReplicatedStorage.Seconds
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = Instance.new("RemoteEvent", ReplicatedStorage)
event.Name = "EndRound"
local plrs = game.Players:GetChildren()

	 
	

local function EndRoundNOW()
	for i, v in ipairs(plrs) do
	    if v.Team == "Playing" then
	        v.Humanoid:TakeDamage()
	    end
	end
	print("someone wants to end the round")
	seconds.Value = 0
end
 
event.OnServerEvent:Connect(EndRoundNOW)


	 
	

2 comments

0

do :GetChildren on the team and for i,v in pairs and kill the players from that

0

Can you give an example through a block of code so that I can mark it as an answer? Thanks for the suggestion, though.

2 answers

✓ Accepted answer
for index,value in pairs(game:GetService("Players"):GetPlayers()) do
	if value.Team == game:GetService("Teams")["Team Name"] then
		pcall(value.Character.BreakJoints,value.Character)
	end
end

Here you go! This does exactly what you wish for.

2 comments

0

Thanks.

0

gj you beat me to it

local plrs = game.Players:GetChildren()

for i, v in ipairs(plrs) do
	if v.Team == Teams["TeamName"] then
		v.Character.Humanoid:TakeDamage()
	end
end

mb made some mistakes but yeah, moon's right

2 comments

0

For me it doesn't work and nothing is in the output...

0

what script do you have? edit your original post

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