For Weapons, Stepped or RenderStepped?

So I have been working on guns and I am quite not sure which one (Stepped or Renderstepped) I should be using.

I believe, in this case, I should be going with Stepped as, with RenderStepped the firing rate gets slowed down as the frames per second goes down. Same when FPS goes up, the firing rate goes up too.

I tried showing my situtation here, is there anything that I’m missing?

Watch Stepped or RenderStepped | Streamable

Tried the other option which is heartbeat?

Yes, it appears to have the same result as Stepped.

Read documentation first so you understand the difference between them.

  • RenderStepped fires before the execution of render ticks (or before frames render). You should only ever be using RenderStepped for updating the camera or something else that relies on the camera (e.g. transparency of local character). Never run anything expensive here.

  • Stepped runs before the simulation of physics. That means before physics updates happen, this will get called. This is ideal in situations where you want a piece of code to run before, say, the update of a part happens. I can’t think of specific cases off the top of my head.

  • Heartbeat runs after the simulation of physics. This means that Heartbeat will go off when parts have updated and a new frame cycle is about to begin. I do not believe it is guaranteed to run as the last event of a frame but this is typically your all-purpose RunService event, good for any case where you don’t want to use wait.

Next, you’ll want this handy chart that shows the order of RunService events firing. It took me a while to understand the diagram but what it essentially shows is a snapshot of two frames in an active game and what events may be occurring within that frame.


Image source @ Fractality_alt, derivative of zeuxcg’s chart

Realistically then, neither. I’d suggest Heartbeat. Remember to also account for the delta time (time between the passage of frames). I would hope you aren’t just attaching the wait method to any of these signals and you’re actually doing some calculations with the delta time parameter, otherwise yeah they wouldn’t exactly appear to make any difference. RunService events are frame dependent.

5 Likes

Jesus, of course I don’t use wait() :smile: and yes, they’re based on deltatime, otherwise the timer wouldn’t work.
Thank you for the chart by the way, now if you’d excuse me I’d like to reconsider some code.

So, Heartbeat it is.

4 Likes