generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do you make a script wait (REWORDED)

Previous Thread :: Next Thread 
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:09 PM
Okay, so apparently people misunderstood my question -_-

When I said "How do you make a script wait for exactly 1 second" I meant EXACTLY 1 second.

The wait(1) doesn't wait 1 second, it waits in a range from 0.99900000001 seconds to 1.00000157 seconds.

So, this makes lots of script's timing horrible. You might have noticed that in some games with a timer, sometimes the timer counts slightly faster than its supposed to, sometimes it counts slightly slower than its supposed to.

This is the reason why in Don't Blink, the players sometimes have the informational gui stuck on their screen when they are supposed to try to hide as an angel.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Jun 2014 05:11 PM
local t = tick ()
wait (t-tick()+1)

Idk, it actually depends on server speed, its roblox bro..
Report Abuse
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:11 PM
So the question: How do you make the script wait for exactly 1 second?
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
01 Jun 2014 05:11 PM
You can't make it wait exactly 1 second, its just not possible with Roblox. And being .000001 seconds behind isn't a big deal. You'd need to run the wait() function one million times for it to be 1 second off, which would take almost 12 days.

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
01 Jun 2014 05:12 PM
Wow, Perfectionist

"Omg honey, I burn't your casserole, I set it to 50.01 Degrees not 50 Degrees"
Report Abuse
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:12 PM
Its not judged by server speed, its because the script itself takes time to log the number, sometimes it makes small errors.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
01 Jun 2014 05:12 PM
*wait(1)* not wait()

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
01 Jun 2014 05:14 PM
Also, it doesn't make the timing of anything horrible because, as I said, you'd need to run wait(1) one million times before you even got one second off.

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:20 PM
Dude, I did do wait(1). Its just that scripts make small errors here and there, and wait() functions are one of the verbs affected by it.
Report Abuse
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:22 PM
Oh yeah, and nothing in scripting is accurate. You can do math.random(1, 3). Sometimes it will do 0.99999999999 or 3.00000000000001. It never is accurate, and the script still logs these two values as greater than 1, less than 3.

This is what I learned after studying how my game worked very, very carefully.
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
01 Jun 2014 05:22 PM
" Its just that scripts make small errors here and there"

Use

repeat wait() until -- until it finds its object

code
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
01 Jun 2014 05:23 PM
The wait() function is basically your only option.

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Jun 2014 05:23 PM
Time = 1
t = tick()
wait (Time)
print (t-tick())

Tell me the output, theres less difference than the human mind can even tell
Report Abuse
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:23 PM
Oh yeah, and nothing in scripting is accurate. You can do math.random(1, 3). Sometimes it will do 0.99999999999 or 3.00000000000001. It never is accurate, and the script still logs these two values as greater than 1, less than 3.

This is what I learned after studying how my game worked very, very carefully. Of course, I may be wrong about the math.random() statement, but the wait() isn't caused by lag, nor is it caused by too many wait() functions, its caused by a phenomenon that occurs often in scripting.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Jun 2014 05:25 PM
Check the wiki on wait ()
itll wait close enough to that time, depending on the client/server itself
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
01 Jun 2014 05:25 PM
@silver

That's not true. When given integers as an input the random function can't return a double, it has to be an integer.

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:28 PM
@swimguy

I said I might be wrong about the math.random part.



@Islandmaker

It outputted 1.016659736633
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
01 Jun 2014 05:33 PM
It's impossible to wait exactly 1 second. Impossible. The closest we can get is counting 9,192,631,770 oscillations of the cesium 133 atom, which takes about 1,400,000 million years to be off by 1 second.

That's as accurate as we can possibly get and it's STILL not 100% accurate. So deal with the fact that wait(1) is one 1 millionth of a second off.

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
SilverArgentum is not online. SilverArgentum
Joined: 01 Nov 2011
Total Posts: 1162
01 Jun 2014 05:41 PM
@swimguy

k
Report Abuse
ayub32 is not online. ayub32
Joined: 27 Dec 2009
Total Posts: 485
01 Jun 2014 05:45 PM
Just being curious, do you have OCD?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Jun 2014 11:25 PM
yeah, because people totally notice 1/1000th of a second extra/less
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Jun 2014 11:28 PM
Why do people expect computers to be infinitely perfect?
Get over it, many people already complained on this forum "why doesn't wait give me perfect time"
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
01 Jun 2014 11:31 PM

wait(t)

Yields the current thread until t seconds have elapsed. If t is not specified, then it yields for a very short period of time (usually close to 1/30th of a second). The function returns 2 values: The elapsed time and the current place time.



print(Wait(1))

1.004991560393 566.78806415454
Report Abuse
DerProgrammierer is not online. DerProgrammierer
Joined: 16 Aug 2007
Total Posts: 12992
01 Jun 2014 11:33 PM
lastTime = tick();

while true do
wait()
now = tick()
if now - lastTime <= 1000 then
--do something
lastTime = now
end
end


Want to learn Java? Contact me or visit http://www.roblox.com/Groups/group.aspx?gid=632774
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Jun 2014 11:33 PM
That's even worse.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image