Categories > Coding > Lua >

How to pause a script?

New Reply

Posts: 2

Threads: 1

Joined: Mar, 2025

Reputation: 0

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?

 

local player = game:GetService("Players").LocalPlayer  
player.Character:MoveTo(Vector3.new(-95, 150, 0))
--sleep(0.5)
player.Character:MoveTo(Vector3.new(-100, 150, 65))
  • 0

  • Comment

_realnickk

Security Researcher

moderator

Posts: 37

Threads: 3

Joined: Feb, 2020

Reputation: 88

Replied

task.wait or use coroutines to resume threads on demand

edit: yield not resume

Comments

sen0 0 Reputation

Commented

It turned out as I expected, thank you!

  • 0

  • 1

  • Comment

Massive computer geek. I focus on cybersecurity now but I pop on randomly to drop lore. https://github.com/reversed-coffee

Posts: 725

Threads: 71

Joined: Oct, 2022

Reputation: 29

Replied

Either wait or task.wait but task.wait is usually prefered for better practises.

  • 0

  • Comment

Languages - C++, C#,Javascript, HTML, CSS, Lua ,Xaml, Python

https://dsc.gg/hackerpluto

Login to unlock the reply editor

Add your reply

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )