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

Why won't player's visor texture change depending on torso brickcolor?

Asked by 3 years ago

I am trying to change a character’s visor (There’s a startercharacter that has one) when a player joins the game. It can pick between four different colors and each one has a corresponding visor texture. When I test it, I don’t get any errors but the visor does not change

game.Players.PlayerAdded:Connect(function(player)
    local character = player.CharacterAdded:Connect(function(character)



        local colors = {
            BrickColor.new("Bright red"),BrickColor.new("Sea green"),BrickColor.new("Electric blue"),BrickColor.new("Bright yellow")
        }

        character.Torso.BrickColor = colors[math.random(1,#colors)]
        if character.Torso.BrickColor == ("Electric blue") then
            character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=42944896"
        else 
            if character.Torso.BrickColor == ("Bright red") then
                character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=1163671"
            else
                if character.Torso.BrickColor == ("Bright yellow") then
                    character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=42580749"
                else
                    if character.Torso.BrickColor == ("Sea green") then
                        character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=20264549"


                    end
                end

            end
        end
    end)
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Instead of using else everytime, use elseif. It's better and will probably make everything work.

Ad

Answer this question