RunService API Documentation code about 'speed' shows major typos

In the RunService API documentation on the Developer Hub, a bit of code with the speed and deltaPosition without a proper declaration about what each variable does and what is the main corresponding function to it. When you put it in Roblox Studio or read it, it is hard for the user reading to learn what each variable does or the main local variable:


When inside Roblox Studio, there are no local variables and it’ll show a warning or unknown function about how or what each variable does other than multiplying * and dividing /. Along with this, we don’t know the local variable for all of the functions…

-- Note: delta just means "change in/of"
speed = deltaPosition / deltaTime
deltaPosition = speed * deltaTime

Not shown above, but the speed, deltaPosition, and deltaTime have errors of an unknown symbol, most known as W000.

For me as a developer, it is impossible to know what these mean or what order they belong in or understand how we can divide or multiply an Integer or :GetService()? If it is just an example of these variables with the comment, then that is a bad representation of how this example is shown and a bad way for beginner developers learning RunService().

1 Like

Hey! Thanks for this feedback, I’ve made sure it’s in our backlog, and we’ll get to it in due time :+1:

1 Like

The code block demonstrates the math involved with frame-by-frame calculations. It was a stand-in for a proper math notation, like the following:

v = dx / dt
“Velocity is equal to displacement divided by time passed”

So, therefore when you’re doing frame-by-frame tasks, you are given dt (change in time) provided to you in the firing of the event. Knowing what the velocity of something might be (or how much it should change per frame), you can find out how much something needs to change on a given frame by multiplying:

v * dt = dx
“Displacement is equal to velocity time time passed”

In other words, the intent of this wasn’t to be “proper code”, but rather a demonstration of what the math should look like in code. It’s a segment. I realize the -- comment and the line numbers might imply otherwise though, so I think I’ll change it to use a proper, full-fledged code sample. This was written quickly so developers would understand the importance of the delta-time parameters of the events.


Update. I’ve decided the information isn’t really appropriate for the class description, so I nixed it entirely. I’ve linked to the Task Scheduler article instead, which is much more relevant.

Thanks again for bringing this to our attention!