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

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

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago
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
0
Ok thanks soo much NinjoOnline 1146 — 10y
0
No problem mate. PiggyJingles 358 — 10y
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? NinjoOnline 1146 — 10y
0
Do you mean how to check what team a player is on? PiggyJingles 358 — 10y
View all comments (5 more)
0
game.Players.TeamColor == "Bright blue" > game.Players.TeamColor == "Bright red" then I think this it it?? NinjoOnline 1146 — 10y
0
Editted my post PiggyJingles 358 — 10y
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 NinjoOnline 1146 — 10y
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 NinjoOnline 1146 — 10y
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 NinjoOnline 1146 — 10y
Ad
Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago
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.

Answer this question