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
 

Have An Event Take Place When A Countdown is Finished

Previous Thread :: Next Thread 
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 12:25 AM
Hi,

I'd like for an event to take place that when a timer is finished counting from 10, a value in Workspace named 'GameV's value would be '2.' This is what I have so far...

GameV = script.Parent.Parent.GameV

function works()
while true do
script.Parent.Value = script.Parent.Value - 1
wait(1)
end
end

repeat works() until
script.Parent.Value == 0

if script.Parent.Value == 0 then
GameV.Value = 3

end
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 12:37 AM
Please somebody help...
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
18 Mar 2014 12:40 AM
GameV = script.Parent.Parent.GameV

function works()
if script.Parent.Value == 0 then
GameV.Value = 3
else
script.Parent.Value = script.Parent.Value - 1
wait(1)
end
end

script.Parent.Changed:connect(function() works end)
Report Abuse
CheesyOwnage is not online. CheesyOwnage
Joined: 15 May 2010
Total Posts: 103
18 Mar 2014 12:41 AM
Are you getting any errors in the Output? If so, post them here.
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 07:43 AM
I used the script @2 above and it said that it was unable to take place.
Report Abuse
Clickest is not online. Clickest
Joined: 06 Aug 2013
Total Posts: 6504
18 Mar 2014 08:14 AM
You Don't Need To Capitalize The First Letter In Each Word.


-Clickest
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 08:46 AM
So far, it counts down perfectly, but when it gets to 0, it goes to the negatives.
Report Abuse
Aesthetical is not online. Aesthetical
Joined: 01 Jan 2014
Total Posts: 2141
18 Mar 2014 09:01 AM
I think I can see why.

You see, when you first called the function works(), you started a while true loop right?

However, that while true loop will go on forever and ever, since you didn't tell it where to stop, or stop it manually.

A way to do this would be to make an "if" statement that checks the value each time it loops. See like this:

function wait()
while true do
if script.Parent.Value ~= 0 then
script.Parent.Value = script.Parent.Value - 1
else break()
GameV.Value = 3
end
end
end

In this script, I removed the unnecessary repeat(the while loop already repeats the works() ), added the "if this equals zero then" inside works() and finally, used the break() function to stop the loop once it reaches 0.
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 09:03 AM
Ahhhhhh. Ok. Thanks. I thought it might have to do with an 'until' state ment, but now I know. Thanks for walking me through it!
Report Abuse
Aesthetical is not online. Aesthetical
Joined: 01 Jan 2014
Total Posts: 2141
18 Mar 2014 09:03 AM
Wait, actually don't use break(), simply use break. Lol :P
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 09:15 AM
Ok. Just curious, though, what's the difference?
Report Abuse
Aesthetical is not online. Aesthetical
Joined: 01 Jan 2014
Total Posts: 2141
18 Mar 2014 11:26 AM
break() was a mistake I made. There aren't supposed to be any parenthesis.
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 03:07 PM
I took out the parentheses on 'break()' and now, the line where it says "GameV.Value = 3" is underlined in red and it says 'end expected near GameV.' I tried adding more ends and it didn't work.
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 03:14 PM
Bump
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 03:41 PM
Bump1
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 05:25 PM
Bump2
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 06:21 PM
There has got to be some way to do this...
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Mar 2014 06:24 PM
local timer = script.Parent.Parent.GameV

while true do
     while timer.Value > 0 do
          timer.Value = timer.Value - 1
          wait(1)
     end
     --anything under here will run when the timer is done
     timer.Value = 3
end

is this what you want?
Report Abuse
MrParkwizard is not online. MrParkwizard
Joined: 28 Feb 2011
Total Posts: 679
18 Mar 2014 06:26 PM
num = 60
repeat
num = num - 1
until num == 0
--Insert code here
This will countown form 60
Report Abuse
MrParkwizard is not online. MrParkwizard
Joined: 28 Feb 2011
Total Posts: 679
18 Mar 2014 06:26 PM
num = 60
repeat
num = num - 1
wait(1)
until num == 0
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 06:35 PM
Thank you both. However, cnt's is the one I need. I will try it in a second...
Report Abuse
MrParkwizard is not online. MrParkwizard
Joined: 28 Feb 2011
Total Posts: 679
18 Mar 2014 06:44 PM
don't use cnts, his will stop at 1, not 0, mine also is more efficient
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Mar 2014 06:45 PM
No, mine will stop at zero, and yours won't reset when he changes the value and it's not more efficient.
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
18 Mar 2014 07:58 PM
@cnt, yours broke my whole game - @park, how do you make it go back to 60 when its done counting down?
Report Abuse
Aesthetical is not online. Aesthetical
Joined: 01 Jan 2014
Total Posts: 2141
18 Mar 2014 08:40 PM
I'll be honest, scripting from a phone is hard, especial if you can't debug your own code.

Try removing the 1st while true loop in cnt's script. I think that might be the cause of the problem.


----------------
local timer = script.Parent.Parent.GameV

while timer.Value > 0 do
timer.Value = timer.Value - 1
wait(1)
end
--anything under here will run when the timer is done
timer.Value = 3
----------------
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 2Go to page: [1], 2 Next
 
 
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