Good-bye camelCase, Hello delay()
by Erik Cassel
Note: This is one of those highly technical articles. If you want something lighter then go here.
The latest build is primarily bug-fix release. However, we’ve added a couple of small scripting enhancements recently.
First, you may have noticed that most object members are now capitalized rather than “camelCase”. We’re supporting old scripts that call member functions that start in lower-case, but all new members will start with an upper-case character. (We’ve decided to standardize on the .NET style with regards to capitalization)
Second, there’s a new global function called “delay”. It complements the wait() function that many of you use. delay takes 2 arguments: The first is a time to wait in seconds, the second is the function to call after the wait time has elapsed. delay continues executing, unlike wait, which blocks.
You’ll find delay is a very useful way to spawn a thread. You might use it in place of connecting to a Heartbeat event and then disconnecting later on. For example, the following code will print “Hello” and “world” followed by “!” a second later:
c = game:GetService("RunService").Heartbeat:connect(exclamation)
Here is the same functionality written with delay: