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 to make a script count backwards?

Previous Thread :: Next Thread 
cyclone3260 is not online. cyclone3260
Joined: 23 Aug 2010
Total Posts: 1038
07 May 2012 01:54 PM
e.i: "for i=1,5 print(i)" That will count 1 to 5 but "for i=5,0 print(i)" It won't count backwards... .____.




Explain please.....
Report Abuse
TheLuaNoob is not online. TheLuaNoob
Joined: 04 May 2012
Total Posts: 482
07 May 2012 01:56 PM
for 1 = 10, 1, -1 print(i)

~!~ Plus One Post ~!~
Report Abuse
TheLuaNoob is not online. TheLuaNoob
Joined: 04 May 2012
Total Posts: 482
07 May 2012 02:02 PM
Mine shows you how to fix it. If you want me to fix it for you just use this


for i = 10, 1, -1 do
print("Count down - "..i)
wait(1)
end




~!~ Plus One Post ~!~
Report Abuse
TheLuaNoob is not online. TheLuaNoob
Joined: 04 May 2012
Total Posts: 482
07 May 2012 02:10 PM
Move useful

for i = 10, 1, -1 do
workspace.Message.Text = ("Count down - "..i)
print("Count down - "..i)
wait(1)
end
workspace.Message.Text = ("Happy new year!")
print("Happy new year!")



~!~ Plus One Post ~!~
Report Abuse
juriaan is not online. juriaan
Joined: 25 Nov 2008
Total Posts: 939
07 May 2012 02:53 PM
Or just simplified.

for i = 1, 10 do
Workspace.Message.Text = "Seconds till launch "..10 - i
wait(1)
end

But I recommend Luanoob way.


Report Abuse
TheLuaNoob is not online. TheLuaNoob
Joined: 04 May 2012
Total Posts: 482
07 May 2012 03:01 PM
I only added the the prints because he wanted to make it print.

~!~ Plus One Post ~!~
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
07 May 2012 03:06 PM
local i=10
local m=Instance.new("Message",Workspace)
repeat i=i+1 m.Text="Seconds untill launch: "..i until i>=0

Hrm.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
07 May 2012 03:14 PM
@wood - That was unnecessarily inefficient.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
07 May 2012 03:18 PM
@Electris

It's shorter than their scripts; and works better

kk ty
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
07 May 2012 03:19 PM
SHORTER doesn't matter. EXECUTION matters. You executed more code, therefore you were more inefficient.

kk ty
Report Abuse
TheLuaNoob is not online. TheLuaNoob
Joined: 04 May 2012
Total Posts: 482
07 May 2012 03:21 PM
I agree with ElectricBlaze

You guys keep telling me to make my scripts shorter, But if they work fine, Why?

~!~ Plus One Post ~!~
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
07 May 2012 03:22 PM
local m=Instance.new("Message",Workspace)
for i=10,1 do
if i~=0 then
wait(1)
m.Text="Seconds until launch: "..i
break
end
end



Does that really make you happier? Meh.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
07 May 2012 03:23 PM
local m=Instance.new("Message",Workspace)
for i=10,0 do
if i~=0 then
wait(1)
m.Text="Seconds until launch: "..i
end
break
end
*


I'm not telling anyone to script shorter, I just like to make mine shorter. Personal quirk.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
07 May 2012 03:24 PM
Now you actually did it WRONG.

You can't go from 10 to 1 at an increment of 1. The if statement is COMPLETELY unnecessary, and without it the same thing would happen. Same with the break statement.

Corrected, that should be:

local m=Instance.new("Message",Workspace)
for i=10,1,-1 do
wait(1)
m.Text="Seconds until launch: "..i
end
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
07 May 2012 03:25 PM
ya - no

u c cus
im speeshal an lua knes that
it maek exception fo' me.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
07 May 2012 03:28 PM
I'm sorry, this is kind of pathetic. You're corrected, and all of a sudden, you're reduced to a troll with little, if none at all, grammar.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
07 May 2012 03:32 PM
Yes. I'm that immature.

OWAITTTTTTT

My first script was right. I'm still happy c:
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
07 May 2012 03:35 PM
By "first one", do you mean the repeat loop or your [failed] for loop? The repeat loop was a fail because it was ridiculously inefficient for something so simple, and the for loop was a fail because it didn't even work.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
07 May 2012 03:37 PM
ok bcus of u i put sad fac on all my posts now

:c
Report Abuse
L2000 is not online. L2000
Joined: 03 Apr 2008
Total Posts: 77448
07 May 2012 04:03 PM
You could also do this:

for i = -10,-1 do
print(math.abs(i))
end

Less efficient, though. I recommend for i = 10,1,-1 do.
Report Abuse
cyclone3260 is not online. cyclone3260
Joined: 23 Aug 2010
Total Posts: 1038
07 May 2012 06:22 PM
Wow thanks guys. cc:
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