While True do script only runs once

I have a while true do script which isn’t throwing errors but also only runs once.

x = script.Parent.Torso.PitchNRoll
Pilot = game.Players:GetPlayerFromCharacter(script.Parent)
h = game.ReplicatedStorage.GetMouseHit:InvokeClient(Pilot)
while true do
	x.CFrame = (h)

I don’t know why this is, but InvokeClient is unsafe and it may have something to do with the script not getting a response.

If anyone can tell me what is going on, whether it is actually going into infinite yield, or how I can solve the problem would be greatly appreciated.

Try while wait(0.01) do maybe that will work

your script is running only once probably because you’re returning from the client only once, try to put the h into the while true loop
but that would cause bad performance due to its firing the client every 0.01 sec.

Spot on.

There’s nothing else in the script that would yield other than InvokeClient

You should never use InvokeClient, you’re better off making your own custom implementation that emulates it like dual purpose remote events

  1. Use task.wait(0.01) instead of wait().
  2. Using InvokeClient is pretty useless and can be insecure mostly. So try to use a custom method [ could be with remotes ].
  3. ‘h’ should be within the loop , although - this would cause some bad performance.

It’s mostly one way, anyway. I changed it to a one-way remoteevent and it works.