Is having more than one RenderStepped event bad?

Hi, let’s say a client has one render stepped event that connects to a function that makes the player shift lock, and another render stepped event that connects to a function that moves the player’s head towards the camera. Like this:

RunService.RenderStepped:Connect(function()
  ShiftLockPlayer()
end)

--In a separate script
RunService.RenderStepped:Connect(function()
  MoveHead()
end)

Would this be inefficient and cause lag? Or would it be better to keep them in the same event like this?

RunService.RenderStepped:Connect(function()
  ShiftLockPlayer()
  MoveHead()
end)

And this is just an example situation, maybe some games I would need to have more than 5 render stepped dependent scripts, or maybe other games I would need to use server scripts instead of local scripts.

As long as you don’t do to many, memory should be fine.

You can also use RunService:BindToRenderStep instead of a connection.

For your current connections, connect them directly to the thread.
RunService.RenderStepped:Connect(threadName)

No, it is not bad. Both examples accomplish the exact same thing. Is there a slight performance difference? Maybe. But it’s so miniscule that you wouldn’t even be able to measure it effectively.

This is going to come down to code structure/organization.

The only important difference in your example is whether or not the ordering of each function is important. If so, you should keep them within the same event connection, or use BindToRenderStep with different RenderPriorities.

4 Likes