Replicating a random int in multiplayer

Hello!
I have a power up that i can spawn. This power up spawns with a random material, and light color. This is chosen with a random integer with the range of 0 ->4. This works 100% in single player, and server side. However the client seems to re do the random integer, and thus spawn with a different material, and light color after i set the variable to replicated.

How can i set this integer to be the same for both client, and server side?

Thanks man, worked like a charm. I had a feeling it was being randomized across all clients, just new to the engine, and didn’t know how to fix it.

Hey,

You’re doing the replication wrong. You want to set the variable to a repnotify, rather than replicated. Then next you want to set the random int on the server(not multicast).

Then go to functions and there you see a newly created function called OnRepSomething and in that variable do the part that comes behind the int set.

Reason why it doesn’t work is because you’re doing the random on all clients rather than the server.