What this BP supposed to do is: the server generates a random float and store it inside a replicated variable, then both the server and client prints its value. The loop is executed 3 times. The values should be same for the client and server all 3 times this is executed.
What I think is happening is that the authority node executes the whole loop and when it finishes, then the remote executes the whole loop, thus only the last value is the same. I wanted the authority to execute once, then the remote to execute once. And repeat this 3 times. How should I correctly do this?
Why are you having the client and server generate random spread?
You want the client to fire a local shot immediately for responsiveness (client-side prediction). You also want the servers shot results to closely match the clients for immersive purposes.
Client sees local shot hit a certain point in 3D space, servers needs to be approximate.
Two approaches…
Maintain Server Authority
Server generates an array of spreads that is replicated to all clients once game starts. Clients then upon firing choose a random from the array and use it for its local fakey shot. Then pass the used Index to the server. Server in turn uses the index to get the matching spread for its “authoritative” shot.
Random Gen on Client, Validate on Server
Client executes a loop to generate 3 spread values. It uses those values for its “local shots”, then passes them to server in a single RPC. Server receives and validates the Randoms are within range. If Valid it fires the “authoritative shots” using those values.