setTimeout and setInterval for roblox-ts.
import { setTimeout } from "rbx-timeout"
const timeout = setTimeout(() => {
print("This will print in 1000 milliseconds (1 second).")
}, 1000)
import { setTimeout, clearTimeout } from "rbx-timeout"
const timeout = setTimeout(() => {
print("This will NOT print in 1000 milliseconds (1 second).")
}, 1000)
clearTimeout(timeout)
import { setInterval } from "rbx-timeout"
const interval = setInterval(() => {
print("This will continue to print every 1000 milliseconds.")
}, 1000)
import { setInterval, clearInterval } from "rbx-timeout"
const interval = setInterval(() => {
print("This is now functionally equivalent to setTimeout.")
clearInterval(interval)
}, 1000)
import { Timeout } from "rbx-timeout"
const timeout = new Timeout(() => {
print("This will not print")
}, 1000) // equivalent to setTimeout
timeout.clear() // equivalent to clearTimeout
import { Interval } from "rbx-timeout"
const interval = new Interval(() => {
print("This will not print")
}, 1000) // equivalent to setInterval
interval.clear() // equivalent to clearInterval