Categories > Coding > Lua >
How to pause a script?
Posted
I need to teleport a character to different points in a loop with a small delay before each next teleportation. How to implement this delay?
Cancel
Post
Replied
task.wait or use coroutines to resume threads on demand
edit: yield not resume
Cancel
Post
Security researcher, low-level programmer, and system administrator.
https://github.com/reversed-coffee
Replied
Either wait or task.wait but task.wait is usually prefered for better practises.
Cancel
Post
Languages - C++, C#,Javascript, HTML, CSS, Lua ,Xaml, Python
https://dsc.gg/hackerpluto
Replied
local player = game:GetService("Players").LocalPlayer
player.Character:MoveTo(Vector3.new(-95, 150, 0))
task.wait(0.5)
player.Character:MoveTo(Vector3.new(-100, 150, 65))
Use task.wait() instead of wait() for better performance and accuracy.
Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Comments
sen0 0 Reputation
Commented
It turned out as I expected, thank you!
0