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

Hide character head if on specific team not working?

Asked by 6 years ago

This script is perfectly fine except for one line, which is the head transparency part. Is anyone able to fix this? Thanks.

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CharacterAdded:connect(function(Char)
        wait(0.5)
        local Contents = Char:GetChildren()
        for _, v in pairs(Contents) do
            if v:IsA("Accessory") then
                v:remove()
            end
        end
        if Plr.TeamColor == BrickColor.new("Bright blue") then
            local Hat1 = game.ServerStorage.Hat1:Clone()
            Hat1.Parent = Char
            Char.Parent:findFirstChild("Head").Transparency = 1 --THIS LINE
        end
    end)
end)

1 answer

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

You have Char.Parent to find the head when right before, Char was the character.

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CharacterAdded:connect(function(Char)
        wait(0.5)
        local Contents = Char:GetChildren()
        for _, v in pairs(Contents) do
            if v:IsA("Accessory") then
                v:remove()
            end
        end
        if Plr.TeamColor == BrickColor.new("Bright blue") then
            local Hat1 = game.ServerStorage.Hat1:Clone()
            Hat1.Parent = Char
            Char:FindFirstChild("Head").Transparency = 1
        end
    end)
end)

Ad

Answer this question