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

Help With Teleporting Players And Team Setting?

Asked by
Scootakip 299 Moderation Voter
9 years ago
01function getPlayerNumberInTeam(TeamColor)
02local num = 0
03for index,player in pairs(game.Players:GetChildren()) do
04if tostring(player.TeamColor) == TeamColor and not player.Neutral then
05num = num+1
06end
07end
08return num
09end
10 
11print(getPlayerNumberInTeam(tostring(game.Teams.Dead.TeamColor)))
12wait(1)
13 
14local debounce = true
15while debounce == true do
View all 27 lines...

Ok, so it's easier for people to help me with this, I will explain what every part of the script does (or at least what it's supposed to do).

1function getPlayerNumberInTeam(TeamColor)
2local num = 0
3for index,player in pairs(game.Players:GetChildren()) do
4if tostring(player.TeamColor) == TeamColor and not player.Neutral then
5num = num+1
6end
7end
8return num
9end

This is a function that gets the number of players in a certain team that you input the color of post-function script.

1print(getPlayerNumberInTeam(tostring(game.Teams.Dead.TeamColor)))

This will use the function to print the number of players in the team color or teamname.teamcolor that you insert at the end of the command there.

1local debounce = true
2while debounce == true do
3    if getPlayerNumberInTeam(tostring(game.Teams.Death.TeamColor)) == 0 or getPlayerNumberInTeam(tostring(game.Teams.Runners.TeamColor)) == 0 then
4        debounce = false
5        wait()
6    end
7    wait()
8end

This is supposed to wait until there aren't any players in one of the two teams: Death or Runners

1for i, player in ipairs(game.Players:GetChildren()) do
2    player.TeamColor = game.Teams["Dead"].TeamColor
3    player.Character:MoveTo(game.Workspace.SpawnLocation.Position + Vector3.new(0, i * 5, 0))
4end

It should then put everyone in the team "Dead" and teleport them to the spawn point.

The script makes it up to the part where it checks Death and Runners for players, but then it doesn't do anything. Some help?

0
could you explain more? What do you mean by "It does things and works fine if I set one of the teams to Dead, but otherwise it doesn't work."? bubbaman73 143 — 9y
0
Sorry, I fixed it. That part should've been there, it didn't make sense and I'm not sure why I typed that. Scootakip 299 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

The problem is at line 16, you're not checking if the number of player is not equal to 0. Instead you're checking if the number of players is 0.

Line 16 should be: if getPlayerNumberInTeam(tostring(game.Teams.Dead.TeamColor)) ~= 0 or getPlayerNumberInTeam(tostring(game.Teams.Runners.TeamColor)) ~= 0 then

Ad

Answer this question