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 » Scripters
Home Search
 

How to make the ":" work in timers?

Previous Thread :: Next Thread 
ExplodeLikeAVolcano is not online. ExplodeLikeAVolcano
Joined: 02 Nov 2013
Total Posts: 12146
02 Oct 2016 10:30 PM
I want to make a timer in my shop GUI like a limited time offer that counts down a time, the time I want to use is "23:59:00" with the : in it, but it won't countdown because the : is not acceptable.

But when I remove the : the script works.. :/


Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
02 Oct 2016 10:32 PM
for seconds = 666, 0, -1 do
print(string.format("%.2d:%.2d:%.2d", math.floor(seconds/3600)%24, math.floor(seconds/60)%60, seconds%60))
wait(1)
end
Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
02 Oct 2016 10:33 PM
make 5 guis

layout:


Hours|:|Minutes|:|Seconds


| used to represent individual text labels

make sure to put the outline to 0 (transparent)


Report Abuse
ExplodeLikeAVolcano is not online. ExplodeLikeAVolcano
Joined: 02 Nov 2013
Total Posts: 12146
02 Oct 2016 10:34 PM
^Sounds sophisticated.


Report Abuse
ExplodeLikeAVolcano is not online. ExplodeLikeAVolcano
Joined: 02 Nov 2013
Total Posts: 12146
02 Oct 2016 10:36 PM
because then I would need 3 separate scripts, and wouldn't they all be counting down..


Report Abuse
CodeBreadpudding is not online. CodeBreadpudding
Joined: 24 Aug 2016
Total Posts: 1286
02 Oct 2016 10:38 PM
"because then I would need 3 separate scripts, and wouldn't they all be counting down.."

This is hilarious.
Report Abuse
ExplodeLikeAVolcano is not online. ExplodeLikeAVolcano
Joined: 02 Nov 2013
Total Posts: 12146
02 Oct 2016 10:40 PM
um..I'm not very good with scripting, so go ahead and laugh.


Report Abuse
CodeBreadpudding is not online. CodeBreadpudding
Joined: 24 Aug 2016
Total Posts: 1286
02 Oct 2016 10:42 PM
You can manage all three objects from one script, even I knew that when I started scripting. I guess everyone is different though.
Report Abuse
ExplodeLikeAVolcano is not online. ExplodeLikeAVolcano
Joined: 02 Nov 2013
Total Posts: 12146
02 Oct 2016 10:44 PM
Could you make one for me? If not, it's fine.


Report Abuse
CodeBreadpudding is not online. CodeBreadpudding
Joined: 24 Aug 2016
Total Posts: 1286
02 Oct 2016 10:48 PM
I never liked making things for people unless I was paid or if they would learn something from it. If I gave you a script you wouldn't learn from it and would instead just copy/paste it. So I give you this challenge: Learn how to control objects in scripts, the Lua string patterns and finally basic Lua.

http://wiki.roblox.com/index.php?title=Intro_to_Scripting
http://wiki.roblox.com/index.php?title=String_pattern
Report Abuse
ExplodeLikeAVolcano is not online. ExplodeLikeAVolcano
Joined: 02 Nov 2013
Total Posts: 12146
02 Oct 2016 10:50 PM
Thanks!


Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
02 Oct 2016 10:53 PM
local seconds = 59
local minutes = 59
local hours = 24

while true do
seconds = seconds - 1
wait(1)
if seconds == 0 then
minutes = minutes - 1
seconds = 59
if minutes = 0 then
hours = hours - 1
minutes = 59
seconds = 59
if hours == 0 then
hours = 0
minutes = 0
seconds = 0
script.Disabled = true
end
end
end
end



its really crappy and starts over when you die, but im just trying to give you a step in the right direction.


Report Abuse
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
02 Oct 2016 11:48 PM
'string.format("%.2d:%.2d:%.2d", min, sec, millisec)'

use that

it works because it will format the numbers into 2 integer digits and then place a colon

Report Abuse
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
02 Oct 2016 11:52 PM
and you can just convert secs and count down from that using standard division and flooring it

example: secs to mins:

print(math.floor(60/60))
> 1
print(math.floor(30/60))
> 0
print(math.floor(120/60))
> 2
Report Abuse
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
02 Oct 2016 11:53 PM
Make sure that the seconds you are formatting though are:

seconds%60

use modulo to make sure that it never goes over that number but returns the remainder in division
Report Abuse
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
02 Oct 2016 11:55 PM
and also use modulo on the mins and hours too which flux did so that it does not go over 60 or 24
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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