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

Why Wont this work?

i am a Near-Amature scripter so i dont anderstand alot of things. SO f you could help me fix this it would help alot! THANks! CODE:

d = game:GetService("Teams")
if d.Players == 0 then -- Meaning if there is no players in the team

****Again, I am a amature, so i dont understand it, Sorry if this is a request :/

1 answer

It's always best to look stuff up before you use it in your code. As it turns out, the property you are trying to use simply does not exist. To actually get the number of players on a team, it's much more complicated.

We must loop through all the Players and check their TeamColor property, then use a variable to keep track of how many players had that same TeamColor.

local blueNum = 0
for index, player in pairs(game.Players:GetPlayers()) do
	if player.TeamColor == BrickColor.new("Bright blue") then
		blueNum = blueNum + 1
	end
end
print(blueNum)

3 comments

0

Thanks!, but how do i make it so it will run if there's no players on said team?

0

It WILL run if there's no players on the said team. There is nothing to prevent this code from running. I think I'm misunderstanding...?

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