BindToRenderStep doesn't work on a server-side script during online game-play

After running into a consistency issue with RunService:BindToRenderStep between online game-play and studio server game-play, I decided to test RunService:BindToRenderStep and RunService.RenderStepped with some simple functions that simply print a line to the console.

I discovered that RunService:BindToRenderStep…

  • works fine when in a local script on the client’s side, regardless of whether I’m online or in studio
  • works fine when in a script on the server’s side when testing in a server in studio
  • does NOT work when in a script on the server’s side when playing online, and gives no errors

I discovered that RunService.RenderStepped…

  • works fine in a local script on the client’s side
  • gives the error, “RenderStepped event can only be used from local scripts” when in a script on the server’s side

So I’m guessing my issue is the error in the last bullet point is true, and that’s my problem. However, I was completely unaware this was the case and the fact that BindToRenderStep worked on the server-side in studio led me to believe that I wasn’t doing anything wrong.

So I have a few questions…
Why can’t RenderStepped be used server side?
Why does BindToRenderStep still work in a studio test server in a server script?
Why doesn’t BindToRenderStep give an error when it doesn’t work online in a server script?
Is there an alternative to BindToRenderStep that I can use server-side?

1 Like

You can’t utilise the BindToRenderStep function from the server because the RenderStepped event fires when a frame is rendered on the client.

Play solo doesn’t represent an accurate client and server relationship/build, which is why you’re getting mixed results. You can change this by ticking Settings → Studio → Accurate Play Solo or by launching test sessions within studio (simulates client/server build).

Why are you trying to use BindToRenderStep on the server? I am positive there is a better alternative.

5 Likes

Use Heartbeat on the server instead.

Edit: What @byc14 said is documented on the RenderStepped event, but not the BindToRenderStep method for some reason (it probably should be noted there too):

2 Likes

Interesting, since when could Heartbeat be used on the server? I just checked and that is indeed the current functionality however the devhub directly contradicts this.

Weird. The devhub is wrong. I’ve been using Heartbeat server-side for a few years. I’ll make a post to get that corrected.

1 Like

Figured, I was just in the process of doing so. Feel free to make the thread, you learn something every day lol.

1 Like

I wasn’t using play solo. I was using the server and player test functionality in studio.

You’re right, that is strange however don’t rely on it, I’m pretty sure it isn’t intended plus it won’t work outside of your studio testing environment.

I recommend you submit a bug report detailing the current behavior with a repo attached.

There’s no BindToHeartBeat or UnbindFromHeartBeat method though. I would like to be able to bind and unbind the function as it doesn’t always need to run.

It’s a RBXScriptSignal, so connecting to it returns a connection object, that you can disconnect:

local connection = game:GetService("RunService").Heartbeat:Connect(function()
    print("Running...")
end)

wait(3)

connection:Disconnect()
-- will stop printing now
2 Likes

oh right… forgot that was a thing. I hadn’t done any development on roblox for a couple years prior to a few months ago, so some things are still lost in the forgotten land of my brain.

Roblox Studio is using a new version of Play Solo which uses a server/client model similar to the existing Start Server / Start Player modes. If you’re running something in a server script and expect it to run as a LocalScript in Play Solo, this will no longer work correctly.

1 Like

I ran into this in 2024; same wacky unexpected behavior. took me wayy to long to debug lol

Definitely needs some sort of error or warning by now,;
even with multiple years of experience on and off the platform, I still spent all night thinking Studio was gaslighting and going crazy on me :rofl:

1 Like