Roblox Script wait

-- Define a function named "waitForSeconds" that takes a parameter called "seconds"
local function waitForSeconds(seconds)
    -- Create a variable called "startTime" and assign it the current time plus the provided "seconds"
    local startTime = os.time() + seconds

    -- Repeat until the current time is greater than or equal to the "startTime"
        -- Yield the script execution until the next frame
    until os.time() >= startTime  -- Check if the current time is greater than or equal to "startTime"

-- Example usage:
waitForSeconds(3)  -- Wait for 3 seconds
print("After waiting for 3 seconds")

This Lua script defines a function named waitForSeconds that halts the execution of the script for a specified number of seconds before continuing. The function uses the os.time() function to get the current time and wait() to pause the execution until the specified time has passed. The provided example demonstrates the usage of the waitForSeconds function by waiting for 3 seconds before printing a message.