variable switches every frame with multiplayer.

Hello, I am trying to use a remote procedure call to set a variable on the other players game.
My problem is, the variable keeps switching between what the client set the variable to and what the server set the variable to. This is stopping my code from reading the correct value of some of my variables. It only happens when there are multiple players on the server.

I am setting the variables with a remote procedure call in blueprints. the rpc changes the variable in c++. in my c++ code I have a line that prints the value of the variable to the screen. when the problem is happening the variable seems to flip between 2 independent values. one of these is set by the local player and the other is set by the remote player.

here is a project that shows the problem happening

If anyone knows why this is happening or how to fix it that would be great.

ps. if I don’t have enough information here, I’m sorry, feel free to ask for specific info.

fixed it. for whatever reason I had multiple instances of my players code running. the remote procedure calls were setting one of the instances variables but not the other, so when I added code to replicate the variable between both instances it fixed the problem.