myGameobject.GetComponent<SpriteRenderer>().Color = new Color(r,g,b);
Make sure that it knows its a SpriteRenderer, and not just a regular renderer. The transform.renderer property is not the good way to access your objects specific renderer, because there are all different kinds of renderers.
If it still isn’t working, you’re going to want to check your sprite to see if it has white or gray colors in the image, because sometimes if you have a non-white / gray sprite, it’s going to look weird when you tint it.