For example, I use:
while true do wait() print("YOUR PLANE HAS BEEN HIJACKED HAHAHAHAHAHA") end
I heard there are more efficient ways to use this.
I heard of:
os.time
tick()
wait(time)
If there are more, let me know and explain.
I know what these are, but I am yet to find out how to use it to it's full potential!
Just asking, not a request
What do you mean? When you want to pause, you wait
. os.time
and tick
aren't meant to pause the thread, they just show you how much time has passed since a certain date. It's best to use os.time
since it's not native to the ROBLOX server's time zone (ROBLOX has servers in different parts of the world). This is useful for getting difference in time.
t1 = os.time() wait(2) t2 = os.time() print(t2 - t1)
wait
is a function that returns 2 values, how long it waited and how long the game has been running. We could use that instead:
wait(5) --To let the game run for a while elapsed, runtime = wait() print(elapsed.."\n"..runtime) --\n is a line break, like pressing enter on the keyboard.
But really, if you just want to pause the game, you wait
.
Well wait() is the fastest amount of time that your studio can process. You can edit this in your studio settings. However, you have to be careful as Lua itself can only be processed so fast. If you want to find out how fast you can make a wait without getting into trouble, I would use RunService:
local RunService = game:GetService('RunService') local LoopCount = 5 local Count = 0 RunService.Heartbeat:connect(function(Step) if Count < LoopCount then Count = Count + 1 print("Time between each loop: "..Step) end end)
But to avoid all this inconvenience, you can say that it is about 1/30 of a second. A little less than a frame. So you can say wait(1/30) for about as fast as you can go.
But tick() is the local time after the UNIX epoch. os.Time is the time of the server. Both will differ depending on the timezone. They just show what time it is. wait() is a set amount of time for the script to wait before continuing.
Hi..I'm on mobile so I can't help that mucb right now but I'll how another way it can simplify it easier.
Example = 5--this is a variable --code here Wait(Example)
There we made a string! Hope this helped let me know of it did