How do you get a color from another game object

I’m working on a paintball game. Where the object that I shoot must get the color that the paintbal in the game has. The paintball color change the hole time so I can’t say that the object must change in a specific color.

my code on the moment is:

but when I run the game I get this error:

I have checked that he can find the object kleur so that isn’t the problem. I hope someone can help me.

The Problem is that Material is not a component itself. It’s part of any Renderer. So you’d need to do the following:

GetComponent<Renderer>().material.color = kubus.GetComponent<Renderer>().material.GetColor("_Color");

P.S.: The left hand side was right already, why did you change syntax on the other?
P.P.S.: Paste your code using the “101010” button next time, making it copyable.