Does firing a remote in a run service loop make the ping high?

Hello, in one of my games there is a script where a remote event is fired in a run service loop, and I was wondering if that could be making the game lag

The code is something like this

local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.Event

RunService.Heartbeat:Connect(function()
	local Speed = Player.Character.PrimaryPart.AssemblyLinearVelocity.Magnitude
	Event:FireServer(Speed)
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.Event

Event.OnServerEvent:Connect(function(Player, Speed)
	Player.Character.SpeedSound.PlaybackSpeed = Speed / 450
end)

The code is changing the speed of a sound

Well, I can’t tell you certainly if this will lag or not, but it is not an approach I would use.
A common workaround for that you will often see is calling this remote less frequently, and when updating the PlaybackSpeed, just use tweening to smooth is accordingly. You can maybe do it directly on the server by listening to whenever AssemblyLinearVelocity changes and then updating it accordingly.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.