Making loops faster than renderstepped

So what I’m trying to do is to make a really quick gun, but the max is 1bullet per renderstep. Is there any way to make it shoots out more bullets without changing the renderstep? Making it two bullets per renderstep isnt the choice.

Like in a minute a gun can only shoot 3600 bullets. Any how to increase the number?


Render stepped is every frame, you cant get any faster then that, just shoot numerous bullets per frame, also Heartbeat is recommended instead.


As CodeNil said, you can’t make it “faster” than RenderStep. But you can simulate it faster by launching several bullets per RenderStep (or Hearbeat which is more reliable) and alternate their velocity and start point. Ie. shoot three bullets per RenderStep where each bullet is offset from one another forward by X distance.


What type of gun fires faster than 3,600RPM?

I want one :eyes:


Fire the bullets in a separate thread recursively. That way you can just wait the rpm between shots instead of renderstepped

You should only be using RenderStepped for rendering, as it fires before any render updates happen. You should be using either Stepped or Heartbeat. They both run parallel to the render updates, but Stepped fires before the physics update and Heartbeat fires after.

Unless, of course, this has to do with GUIs.


The answer here isn’t faster loops, it’s physically positioning the bullets to represent a faster frequency. Anything faster than one frame is practically meaningless, so if you want to fire 2 bullets per frame, put the first one further ahead than the second one.

	for i=1,math.ceil((rpm/60)/60) do

This is the closest way to get > 3,600 rpm in render stepped


You shouldn’t be using RenderStepped for something that isn’t graphical.
Otherwise, the gun would fire slower for people with a poor framerate.
Heartbeat is a consistent 60 fires per second.

Anyway, assuming that the gun fires at 10,000RPM or 167RPS, every Heartbeat you could have the gun chamber 2.8 rounds then fire off the math.floor of the number of chambered rounds.
Frame 1: 2.8 rounds in chamber, fire 2
Frame 2: 3.6 rounds in chamber, fire 3
Frame 3: 3.4 rounds in chamber, fire 3
Frame 4: 3.2 rounds in chamber, fire 3
Frame 5: 3 rounds in chamber, fire 3
Frame 6: 2.8 rounds in chamber, fire 2

While it may sound like a bad solution to fire multiple shots at the same time, no one will notice when there’s 60 bursts a second.

1 Like

That’s exactly what my code above does :confused:


I am both impressed and terrified at once.


Finally the difference between Stepped and Heartbeat. Never thought I’d ever know.


Good god that’s horrific please never use that code

Never said it was good code,it’s the only way to do it.


uh, your code actually very useful. Thank you about that

no dont use it

You’re going to cause some serious issues with roblox if you try to execute instructions more than 60Hz a second

Especially since you’re spawning a new thread each time

1 Like

Why would you wrap it in a spawn? The Lua VM in Roblox is singlethreaded, so only one thread can run at a time anyway. Aside from that, spawn postpones execution until the next frame, so this line of code causes all sorts of strange effects you may not notice straight away. I would just do shoot() instead of spawn(shoot).

PS: Heartbeat or Stepped is better here instead of RenderStepped, probably.

-- this method is very laggy
-- only recommended as last resort

local number = 10 -- the more, the faster (and laggier)

while true do

-- code

if math.random(0,number)==number then task.wait() end