Is there a good Alternative for RunService.Heartbeat?

Heartbeat only runs on localscripts but is there a good Alternative which also runs on serverside scripts ?

I’m not sure but RunService.Stepped.

1 Like

I think you’re referring to RenderStepped, as that only runs in Localscripts, Heartbeat and Stepped work in both Regular scripts and Localscripts I believe. You can use either, Heartbeat runs after physics calculations every frame and Stepped runs every frame before the physics calculations. Or you can also use BindToRenderStep, not sure if this is locked ot localscripts only, if so, use Heartbeat or Stepped, depending on use case

2 Likes

So if i sayRunService.Stepped:Connect(function(20) print("itworks") end)
it will work ?

3 Likes

Yes, if you use that in a Server script or a localscript, it’ll work. Although not sure why you wrote 20 there, Stepped returns 2 things, the time in seconds RunService has been running, and deltaTime, which is the time has elapsed since the previous frame

2 Likes

ja but how doese the server know how many frames the client has

The only way I know how the server can know is to make the client fire their current fps to the server via RemoteEvent, you’d need to do it every once in a while since it could cause problems if you fire it every frame. The server can’t directly grab it since each client will have a different fps

Think this post should help you out

1 Like

So if i say RunService.Stepped:Connect(function(deltaTime) print("itworks") end)
it will print “itworks” every frame. So its like a loop ?

Yes, the event will be ran every frame so it’ll print on ever frame until the event is disconnected