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: Coroutine problem.

Previous Thread :: Next Thread 
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
10 Apr 2013 07:34 PM
Any idea why the brick won't change to the second color when I run this? It will only swap to the first color in the coroutine.

function animate()
coroutine.resume(coroutine.create(function()
while true do
mine.BrickColor = BrickColor.new("Bright red")
wait()
mine.BrickColor = BrickColor.new("Light stone grey")
end
end))
repeat
mine.Transparency = mine.Transparency - .1
sound2:play()
wait()
until mine.Transparency <= 0
end
Report Abuse
dnic1997 is not online. dnic1997
Joined: 08 May 2010
Total Posts: 309
10 Apr 2013 07:37 PM
My first question would be: Is the transparency piece of that function working?
Report Abuse
FoggedOut is not online. FoggedOut
Joined: 09 Dec 2011
Total Posts: 3021
10 Apr 2013 07:39 PM
Would it be:

wait(#)
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
10 Apr 2013 07:39 PM
Yes
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
10 Apr 2013 07:43 PM
-- Could try something like

function animate()
local function col()
mine.BrickColor = BrickColor.new(mine.BrickColor.Name=="Bright red" and "Light stone grey" or "Bright red")
delay(.1,col)
end
col()
for n=mine.Transparency,0,-.1 do
mine.Transparency = n
sound2:Play()
wait()end
end

-- Your real problem was that you had no wait before the while's end
Report Abuse
dnic1997 is not online. dnic1997
Joined: 08 May 2010
Total Posts: 309
10 Apr 2013 07:47 PM
coroutine.resume(coroutine.create(function()
while true do
mine.BrickColor = BrickColor.new("Bright red")
wait()<-----------------------------------------------------------------------
mine.BrickColor = BrickColor.new("Light stone grey")
end
end))
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
10 Apr 2013 07:49 PM
@1Top I'm using a coroutine for it's natural pcall(), yours won't run @ the same time, will it?

-- Your real problem was that you had no wait before the while's end - ?

Everything works fine, except it won't change to the second color, I don't see that as a problem. :o?
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
10 Apr 2013 07:51 PM
Yes, mine will run like a coroutine, the delay function doesn't return the first argument in a wait, so you'll be fine there.
And what I meant was this,

while true do
-- brick color change
wait()
-- brick color change
-- NO WAIT HERE, SO IT'S JUST GOING TO LOOP NOW AND OVERRIDE THE BRICK COLOR CHANGE ABOVE
end
Report Abuse
dnic1997 is not online. dnic1997
Joined: 08 May 2010
Total Posts: 309
10 Apr 2013 07:54 PM
Oh lol, I thought you meant there was no wait() in the while true end, period.
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
10 Apr 2013 07:54 PM
Oh, duh, that was a dumb mistake, thanks.
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
10 Apr 2013 07:55 PM
@dnic no, then studio would have crashed, and he would have known his problem :3
@Azarth you're welcome

-- I was away from Scripting Helpers for almost a month. I MISS THIS PLACE O:
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