Can I set a variable on the server through client input?

Hello,

I attached a few images from the player character’s blueprint.

What I want is for the player to hold down a button, to charge up the initial speed of the spawned projectile (by using a float that increases as the button is held down, i called it Shuriken Speed).
When the player releases the throw button, it executes a Spawn Actor node, with the Initial Speed input connected to the float that sets the throw power (ShurikenSpeed).

The server seems to be detecting input from the client, because the print string after setting ShurikenSpeed is called when playing as the client, but it only returns the string: Server: 0.0

So maybe the problem is that the Get Input Key Time Down is not being replicated to the server through the client? Because it is going through the Set Shuriken Speed node on the server-side, when holding down the button as the client, after all.

I can’t set or get the ShurikenSpeed variable from the client side, because the projectile should spawn server side, and the Spawn Actor node can only get the Initial Speed input from a variable that’s set by the server (if I understand correctly). That’s why I’m wondering if there’s a way to change a variable on the client and replicate it to the server. There’s probably a better way of going about it, but I can’t seem to find a solution that works.

Any help would be greatly appreciated, thank you.

You need to use a Server RPC with a parameter for the shuriken speed. The server has no idea that the client is holding keys down.

I learned that connecting Event Tick to an RPC, and setting any variable client-side, for multiplayer, is not a good idea.

I found a simple solution that works for my scenario: When the InputAction is pressed, the HoldThrowKey event is called. After the DoOnce node in that line (see the images), I added a Timeline node with a Float Track that Plays from Start every time the InputAction is pressed, but stops when released. The Update output of the Timeline node sets the Shuriken Speed variable.

This allowed me to get rid of the Event Tick and the Get Input Key Time Down node. Hope this helps someone.