Three ways to write reworld waiting

Time:2020-3-18

In the reworld editor, there are three ways to write the function of wait time:

1、 Process waiting

In non code blocks, we can use the wait () function to wait directly

In a function or loop, you need to use coroutine to wait

coroutine.start(function()  
    ...  
    coroutine.wait(1)  
    ...  
end)

2、 Use timer timer

local index = 0  
local function hahalog()  
log("sheep count"..index)  
index = index + 1  
end  
local timer = RWTimer:Create(hahalog,1,100)  
timer:Start()

3、 Update function

local gameRun = GetService("GameRun")  
gameRun.Update:Connect(function(delta)  
end)