Need help making a loop as fast as possible (ServerScript)

So basically, i am making a gear that summons a sword from the sky as an Ability, it seems to work fine when Playtesting, but as the server gets laggier, the loop that makes the sword point towards mouse gets lagger (making the wait(1/1000) into a 3 second wait)

here is my code:

for i = 1,90 do --Decent Waiting Time
	RunService.Heartbeat:Wait() --Better than Wait(1/1000)/Custom wait() Function?
	if not TruthBlade then return end
	TruthBlade:SetPrimaryPartCFrame(,Tool.DirectionInvoker:InvokeClient(Player).Position) * CFrame.Angles(math.rad(90),math.rad(0),math.rad(0)))

heartbeat runs every physics step, which is 1/60th a second.

You’re using InvokeClient which will yeild until given a response meaning your loop won’t get any faster than the ping of your client.

InvokeClient is also typically frowned upon as you should never trust the client, and the client can always make this yeild for however long they want which is bad.


I don’t know if I am right or straight up dumb here but, iirc Remote Events don’t return anything. They just send data through. But with Remote Functions, they are expecting a value returned.

Invokes yield a script, whipe events fire and move on. They support return values because theyre like a request: it asks something, and that something is expected to return.
However, when using InvokeClient, exploiters can set the callback function to yield indefinitely, like @WingedDash said

even when the calling script, client and invoker are destroyed?