Math & Task Module
The math module handles numerical helpers, while task covers timing and pauses in scripts.
Math Module
Section titled “Math Module”| Function | Returns | Description |
|---|---|---|
math.random(min, max) | number | Returns a random integer between min and max. |
math.round(n) | number | Rounds n to the nearest whole number. |
math.abs(n) | number | Returns the absolute value of n. |
math.pi | number | The constant value of pi. |
lau-compiler.exe
varol chance = math.random(1, 100)print("Random Number: " + chance)
varol amount = 12.7print("Rounded Value: " + math.round(amount))OUTPUT:
Random Number: 42
Rounded Value: 13
Task Module
Section titled “Task Module”| Function | Returns | Description |
|---|---|---|
task.wait(seconds) | void | Pauses the script for the specified amount of time. |
task.clock() | number | Returns high-precision CPU time. |
task.time() | number | Returns the total time the game has been running. |
task.date() | string | Returns a formatted string of the current date and time. |
lau-compiler.exe
print("Step 1...")task.wait(1)print("Step 2...")OUTPUT:
Step 1...
Step 2...
Timing Example
Section titled “Timing Example”varol startTime = task.clock()
for i = 1, 10 do drone.move(Enum.Direction.East) task.wait(0.5)end
varol elapsed = task.clock() - startTimeprint("Task took " + elapsed + " seconds.")