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

Kill all players and then change their team script?

Asked by 11 years ago

So I've been trying to get this to work all day. I am seething with rage right now. I am ready to launch my game, but cannot because of this. I need it to work once a brick is clicked. I made the part, put the click detector in it, and this is the bit of the script I already have:

1function ClickTime(Plyr)
2for i,v in pairs(Players:GetPlayers()) do
3v.Character:BreakJoints()
4end
5end
6script.Parent.ClickDetector.MouseClick:connect(ClickTime)

However, that didn't work, and It didn't change the teams(Because I still don't know how to do that). So then I tried this:

1local detect = script.Parent.ClickDetector -- Assuming the script is within a part, and the part has a ClickDetector in it
2 
3function kill()
4        for i, v in pairs(game.Players:getPlayers()) do
5        v.Character:breakJoints()
6end
7 
8detect.MouseClick:connect(kill)

And that didn't work either. If someone can help me make these scripts kill all, that would be great. And if you need to know the teams, they are: "Really red" "Bright blue" "Bright yellow" And I am trying to change the teams to yellow.

1 answer

Log in to vote
2
Answered by 11 years ago
01function killandteamchange()
02for i, player in pairs(game.Players:GetChildren()) do
03player.Character.Humanoid.Health = 0
04local numPlayers = 0
05 
06for i, v in pairs(game.Players:GetPlayers()) do
07if v:FindFirstChild("TeamColor") == BrickColor.new("Really Red") then
08numPlayers = numPlayers + 1
09elseif v:FindFirstChild("TeamColor") ~= BrickColor.new("Bright Blue") then
10    numPlayers = numPlayers - 1
11end
12end
13 
14if numPlayers == 0 then
15 
View all 24 lines...

GOD ITS LONG AND IT TOOK LONG.

0
Thank you! Tallestmidget7 95 — 11y
Ad

Answer this question