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(CFrame.new(TruthBlade.HitBox.Position,Tool.DirectionInvoker:InvokeClient(Player).Position) * CFrame.Angles(math.rad(90),math.rad(0),math.rad(0)))
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