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
|
  |
| 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
|
  |
| Joined: 09 Dec 2011 |
| Total Posts: 3021 |
|
| |
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 10 Apr 2013 07:54 PM |
| Oh, duh, that was a dumb mistake, thanks. |
|
|
| Report Abuse |
|
|
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 |
|
|