Rapidly Firing a Remote event to update a value on the server

So I want to fire an event rapidly to update a value that shows the players mouse.Hit for a targeting system.

The current code I have is :

This on the client :

while true do wait(0.07)
game.ReplicatedStorage.Update:FireServer(mouse.Hit)
end

This on the server:

script.Parent.OnServerEvent:Connect(function(player, mHit)

player.Character.Stats.Target.Value = mHit

end)

However, when this happens it causes the error of this
Remote event invocation queue exhausted for ReplicatedStorage.Update

The update simply fires too fast for the game to keep up and it stops firing to save the game from lagging. Atleast thats what I’m assuming

Is there any alternative to this? Thanks.

targeting system…

why you don’t do that on client only? cuz, yea, spamming information
(USING remote events) will cause the error

since i don’t know for what (exactly) you want the targeting system then i cannot help

(i expected a Gun, just manage effects and stuff on client-side)
and when fire a gun you just do that on server-side ( anti exploits )

It is used for moving a move that has a few seconds of start up, therefore the target may have already moved out of the way. So, I’d like to have a constant firing of the mouse.Hit for the location of the move to go to so you can re-aim it if they move.
If that makes sense

yea do that on the client side, because doing that on the server is actually weird
(if you are creating a Target system where others players CAN see that you are
marking him, then this is another topic)

and yes, do that on the client side

because, think about it:

if 50 players are targeting someone at the same time ( the server will explode )

Its not like a target target its like just where your mouse is so the server can see it.

Also I dont get how you’d go about putting it on the client when the event has already fired and sent to the server, done the move cutscene and now I want the mouse position to aim the move to

while true do
    task.wait(0.1)
    game.ReplicatedStorage.UpdateLFireServer(mouse.Hit)
end

script.Parent.OnServerEvent:Connect(function(player, mHit)
    player.Character.Stats.Target.Value = mHit
end)

This could work. The problem is that the amounts of requests the single RemoteEvent is intaking is causing an outage of service provided by it. You could also use the changed event, like this:

mouse:GetPropertyChangedSignal("Hit"):Connect(function()
    game.ReplicatedStorage.Update:FireServer(mouse.Hit)
end)

script.Parent.OnServerEvent:Connect(function(player, mHit)
    player.Character.Stats.Target.Value = mHit
end)

I am not 100% sure if that would work, or if it isn’t a function of mouse, however, if it does, use that vs the infinite loop.

I have taken your advice on using something other than a while loop. Despite your method of mouse:GetPropertyChangedSignal(“Hit”) not working (surprisingly i have no idea why that failed) .A quick google search found this :

UIS.InputChanged:Connect(function(input, engine_processed)
if engine_processed then
return
end
if input.UserInputType == Enum.UserInputType.MouseMovement then
print(“mm”)
game.ReplicatedStorage.Update:FireServer(mouse.Hit)
end
end)

which does… basically the same thing as yours but with more code
The issue is now rapid mouse movement breaks it as it acts like a while loop. My idea is to 1/2 or 1/4 the mouse movement in total (eg every other movement counts) to try reduce strain on the event. Thanks for the help

How to avoid that is to do every 1/4 mouse movement, and add 4 total points to the value.

Surely that’d just make it offset thought, unless I’m interpreting “Add 4 points to the value” wrong.