Help with laggy part

I want to move an object in front of my player using distance relative to how much time has passed:


	local con = RunService.Heartbeat:Connect(function(dt)
		runtime += dt
		
		print(runtime)
		
		baseProjectile.CFrame = hrp.CFrame * CFrame.new(0,0,-runtime*15)
		
		updateProj:FireAllClients({Index = index, UpdateCFrame = true, cframe = baseProjectile.CFrame})
		
		
		
	end)


I was thinking about doing something with making the part move on the client then firing to server, then finally firing to other clients but this could be exploitable, so then I said:

“Maybe I should use my safe remote function” (makes it impossible to exploit remote functions)

then I came to the realization that lag might cause jittering between the remote function requesting the position of the projectile from the firing client, and the firing client moving the projectile on its own client.

My goal is to have some part, stay where the player is facing, increase distance base on time, but also not be mad laggy. BTW the remote event is an unreliableremotevent in case that helps. (networking stuffs I learned)

It is a common misconception that a feature being exploitable means it 100%, absolutely, can never be touched, sometimes you have to have these vulnerabilities, and compensate with good anti-cheat. The general consensus I’m aware of, is to have projectiles run client-side, and then make a call out to the server telling it to run it independently, with the same exact code just without visuals if possible, then make this go out to all clients, doing the same thing, excluding the original client.

Even if the original client is cheating, the server is running this independently too, and can use it’s results to run sanity checks and anti-cheat in order to preserve the security of the game. You were correct to think that running the part on the client would make it smoother.

1 Like