Changing an objects color using: ().material.SetColor

Solution for Changing an objects color using: ().material.SetColor
is Given Below:

I’m trying to make a minigolf game. I am trying to implement a local multiplayer feature. I would love for each player to have their own color, currently, I have three: red, blue, and yellow. The color is determined by the order in which the players play, I am using the mesh renderer to change the color of the ball, I use a line renderer to change the color of the line in front of the ball. I am getting no errors, but the color doesn’t change, it stays the color that I give it in the editor.

private void SetupPlayer(){
    playerNameText.text = playerRecord.playerList[playerIndex].name;

 public void SetupBall(Color color){
    transform.position = startPosition.position;
    angle = startPosition.rotation.eulerAngles.y;
    ball.velocity =;
    ball.angularVelocity =;
    GetComponent<MeshRenderer>().material.SetColor("Color", color);
    line.material.SetColor("Color", color);
    line.enabled = true;
    putts = 0;
    puttText.text = "PUTTS: " + putts.ToString();;

Try "_Color" instead of "Color".