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

How to make a script see what team a player is on??

I'm trying to make a script that checks to see what team the player is on. What would I have to add?? game.Workspace?? is there something in the player that tells you what team their on.

2 answers

✓ Accepted answer
game.Players.TeamColor;

edit: if you meant how to check their team:

if game.Players.TeamColor == "Bright blue" then
	--Do stuff here for their team
elseif game.Players.TeamColor == "Bright red" then
	--Do stuff separately for their team here
end

if you mean how to set their team:

game.Players.TeamColor = "Bright blue";
game.Players.TeamColor = "Bright red";

edit2:

function playerOnTeam(teamColor)
	local players = 0;
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.TeamColor == teamColor then
			return players + 1;
		end
	end
end

if playerOnTeam("Bright blue") > playerOnTeam("Bright red") then
	--Do stuff
end

9 comments

0

Ok thanks soo much

0

No problem mate.

0

Oh, um, how can I get it after teamcolor, what do I add to it like game.Players.TeamColor.Bright blue, how do I do that, cause that dosent work?

0

Do you mean how to check what team a player is on?

0

game.Players.TeamColor == "Bright blue" > game.Players.TeamColor == "Bright red" then I think this it it??

0

Editted my post

0

if game.Players.TeamColor == "Bright blue" > game.Players.TeamColor == "Bright red" then script.Parent.Parent.BlueBlocker.CanCollide = true end This is what I want. I want when there is more on blue team than red, then the blue door gets blocked off by another block

0

to me, what i did with if blue has more players than red then it will block of the door, thats what I want it to do and I though it was

0

players = game.Players:GetChildren() randomp = players[math.random(#players)] print(randomp.Name .. " is killer") game.Players.TeamColor = "Bright red"; for i,v in pairs(players) do if v.Name ~= randomp.Name then print(v.Name .. " is runner") game.Players.TeamColor = "Bright blue"; end end

function getTeam(player)
	if player.Neutral then return end
	for _,v in pairs(game:service("Teams"):children())do
		if v.TeamColor==player.TeamColor then
			return v.Name
		end
	end
end

Returns the name of the team the player is on.

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