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

How can I see how many people are on a team?

I need to track the amount of people on teams to determine who wins the round, however it always says that there are zero people on the teams even if that isn't true. I double checked to make sure it was the correct colors for each team. These are not the names for the teams, however, just in case that might be the issue.

blue = 0
red = 0
while wait(1) do
for _,v in pairs(game.Players:GetChildren()) do
    if v.TeamColor.Name == "Crimson" and v.Neutral == false then
        red = red + 1
    elseif v.TeamColor.Name == "Cyan" and v.Neutral == false then
        blue = blue + 1
    end
end

print("There are "..red.." players on the red team and "..blue.." players on the blue team.")
end

New script that comes up with this error message:Workspace.HidingWin:6: attempt to call a string value

local teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(teams) do
    local players = team:GetPlayers()
    print("Team " .. team.Name .. " has " .. #players .. " players")
	if team.Name("Hiding").. #players > 0 then
		game.Workspace.HidingWinTestA.Value = true
	end
end

1 answer

local teams = game:GetService("Teams"):GetTeams()
for _, v in pairs(teams) do
    local players = v:GetPlayers()
    print("Team " .. v.Name .. " has " .. #players .. " players")
    if v.TeamColor.Name == "Crimson"  .. #players > 0 then
        game.Workspace.HidingWinTestA.Value = true
    end
end


6 comments

0

Thank you, however, I added this: "if team.Name("Hiding").. #players > 0 then game.Workspace.HidingWinTest.Transparency = 0" and this error message came up "Workspace.HidingWin:6: attempt to call a string value" Do you know anything about this?

0

Oh its because your trying to compare a string

0

Edit your script so I can help

0

alr im guessing u mean i should edit the question

0

Edited

0

Please accept my answer

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