Changing color of Gameobjects with a pen-like thing but the sync isnt always working

Hello everyone.

I have an error that doesn’t always occur but sometimes and I really can’t understand why it occurs and how I can fix it.

My context: The following script is on the GameObject, the color of which should be changed with different “pens”. (If I touch the GameObject with a red pen, the GameObject should turn red. etc. I currently have 16 colors.) That means I have prefabs that have two Udon behaviors, one of which is the following script.

The problem: Sometimes it works wonderfully! Sometimes not at all, sometimes only locally. Sometimes the material is only changed when you pick up the GameObject. (It always works locally, but synchronization for the other players sometimes doesn’t work. So far I haven’t been able to find a reason for this.)

The script should also have other pens with a function other than changing the color. One of these pins is supposed to bring the GameObject back into the ObjectPool, which has always worked so far.

All public variables are filled with the important prefabs. The pens that are supposed to change the color are numbered (I tried out a different approach that converts the names of the pens to ints, which can then be used directly - as an alternative to the for-loop, as I would really like to get rid of that.)

I hope you can help me. Because I have been looking for the error and a solution for almost 5 hours…

Thank you in advance!