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

How can i call out the player's Character from a team?

Asked by 7 years ago

Basically, i'm just trying to call out the character from each player on the blue team, but haven't been able to script a solid working script. Does anyone know how to do that? My failed attempt is shown below...

Script:

local BlueTeamPlayers = game.Teams.Blue:GetPlayers()
local BlueHumanoid = BlueTeamPlayers.Character:findFirstChild("Humanoid")

function DeathOfBlueTeam()
    print('1 player death from blue team...just a test')
end

BlueHumanoid.Died:connect(DeathOfBlueTeam)

Thanks for your time! ;)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

EDIT: Alright, here's the code. I fixed it and added some better explaination.

game.Players.PlayerAdded:connect(function(Player)--hook this up to every player that joins
    Player.CharacterAdded:connect(function(Character)--hook this up to their character
        local Humanoid = Character:WaitForChild("Humanoid")--wait for their humanoid
        Humanoid.Died:connect(function(Died)--hook this up to the humanoid's death
            if Player.TeamColor == BrickColor.Blue() then--check team
                print('Someone died on the blue team D:')
            end
        end)
    end)
end)
0
Thanks so much! Seabiscuitz 21 — 7y
Ad

Answer this question