is it ok to have a run service heartbeat connection constantly running on the client?
Yes, it’s generally fine to have a RunService.Heartbeat
connection running constantly on the client, but it depends on how you use it. Here are some key considerations:
When It’s Okay:
- If you’re using it for lightweight operations, like smoothly updating UI elements or handling animations.
- If the code inside the connection is optimized and doesn’t cause performance issues.
- If you disconnect the connection when it’s no longer needed to prevent memory leaks.
When It’s Not Okay:
- If you’re running expensive computations every frame (e.g., heavy loops, unnecessary table operations).
- If you’re handling physics updates, as
Heartbeat
runs after physics updates—useStepped
for physics-related code instead. - If you accidentally create multiple connections instead of reusing one (which can slow down performance).
Best Practices:
- Use
.RenderStepped
for rendering-related updates (if it’s purely visual). - Use
.Stepped
for physics updates.
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.