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

Team change doesn't affect the player's character after changing teams?

Asked by 5 years ago

I'm making a script to change the player's Torso color when they change teams, but its not changing the color. Referencing the Player itself in the Workspace doesn't work either. Idk. Its making me very confused though.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        wait(1)
        local newPlayer = player.Team
        local pTeam = game.Teams
        if newPlayer == pTeam.pesant then
            character.Torso.BrickColor = BrickColor.new("Reddish brown")
        end
        if newPlayer == pTeam.civilain then
            character.Torso.BrickColor = BrickColor.new("Cork")
        end
        if newPlayer == pTeam.gaurd then
            character.Torso.BrickColor = BrickColor.new("Storm blue")
        end
        if newPlayer == pTeam.knigt then
            character.Torso.BrickColor = BrickColor.new("Pearl")
        end
        if newPlayer == pTeam["knigt brigader"] then
            character.Torso.BrickColor = BrickColor.new("Sand green")
        end
        if newPlayer == pTeam["knigt comandor"] then
            character.Torso.BrickColor = BrickColor.new("Bright blue")
        end
        if newPlayer == pTeam["knigt king"] then
            character.Torso.BrickColor = BrickColor.new("Cyan")
        end
        if newPlayer == pTeam.roug then
            character.Torso.BrickColor = BrickColor.new("Sea green")
        end
        if newPlayer == pTeam.viking then
            character.Torso.BrickColor = BrickColor.new("Persimmon")
        end
        if newPlayer == pTeam["viking chieftan"] then
            character.Torso.BrickColor = BrickColor.new("Bright red")
        end
        if newPlayer == pTeam["viking king"] then
            character.Torso.BrickColor = BrickColor.new("Maroon")
        end
    end)
end)

(And yes i'm aware the Teams are the similar to the 'prtty much evry bordr gam ever' game.)

Any Ideas?

1 answer

Log in to vote
0
Answered by
chiurly 15
5 years ago
Edited 5 years ago
game.Players.PlayerAdded:Connect(function(player)

    player:GetPropertyChangedSignal("Team"):Connect(function()
        local character = player.Character
        if character and character:FindFirstChild("Body Colors") then
            character["Body Colors"].TorsoColor = player.Team.TeamColor
        end
    end)

    player.CharacterAppearanceLoaded:Connect(function(character)
        character["Body Colors"].TorsoColor = player.Team.TeamColor
    end)

end)
0
Thanks! GaemMasta 6 — 5y
0
Is there anyway you could make this constantly run so you don't have to reset your character every time? GaemMasta 6 — 5y
0
Updated. chiurly 15 — 5y
Ad

Answer this question