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
 

Re: Is there any way to do this without coroutines?

Previous Thread :: Next Thread 
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 12:33 PM
player = game.Players.LocalPlayer
text = script.Parent:WaitForChild("TextLabel")
sound = script.Parent:WaitForChild("Tick")

local textFade = coroutine.wrap(function()
for i=1,100 do
text.TextTransparency = text.TextTransparency + 0.025
wait(0.05)
end
end)

local bgFade = coroutine.wrap(function()
for i=1,40 do
text.BackgroundTransparency = text.BackgroundTransparency + 0.01
wait(0.05)
end
end)

function onDied()
text.Visible = true
wait(1)
text.Text = "4"
sound:Play()
wait(1)
text.Text = "3"
sound:Play()
wait(0.5)
bgFade()
textFade()
wait(0.5)
text.Text = "2"
sound:Play()
wait(1)
sound.Pitch = 2
sound:Play()
text.Text = "1"
end

player.Character:WaitForChild("Humanoid").Died:connect(onDied)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 12:37 PM
Yes. Split it up into multiple for loops.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 12:38 PM
As in

for i = 1, 15 do --0.5 seconds with wait()
--stuffs
wait()
end
--whatever
for i = 1, 30 do --1 second with wait()
--MORE STUFFS
wait()
end
--EVEN MORE WHATEVER
--OTHER STUFFS!
Report Abuse
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 12:38 PM
Only one for loop can be ran at the same time...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 12:39 PM
You dont NEED to run more, in your example!
Report Abuse
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 12:40 PM
I do. I want the time to tick at the same time as the GUI fades...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 12:41 PM
Take this bit:


local textFade = coroutine.wrap(function()
for i=1,100 do
text.TextTransparency = text.TextTransparency + 0.025
wait(0.05)
end
end)

local bgFade = coroutine.wrap(function()
for i=1,40 do
text.BackgroundTransparency = text.BackgroundTransparency + 0.01
wait(0.05)
end
end)

----------------------------------------------------------------------------

bgFade()
textFade()
wait(0.5)
text.Text = "2"
sound:Play()
wait(1)
sound.Pitch = 2
sound:Play()
text.Text = "1"

You can turn that into

for i = 1, 15 do
text.BackgroundTransparency = text.BackgroundTransparency + 0.01
text.TextTransparency = text.TextTransparency + 0.025
wait()
end
text.Text = "2"
sound:Play()
for i = 1, 25 do
text.BackgroundTransparency = text.BackgroundTransparency + 0.01
text.TextTransparency = text.TextTransparency + 0.025
wait()
end
for i = 1, 5 do
text.TextTransparency = text.TextTransparency + 0.025
wait()
end
sound.Pitch = 2
sound:Play()
text.Text = "1"



Not as nice, but no coroutines.
Report Abuse
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 12:43 PM
I'd rather have it with coroutines other than ruin it. I was just asking if it was possible or not to achieve the same effect.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 12:44 PM
That IS the same effect!
Report Abuse
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 12:45 PM
It's not at all. The gui doesn't fade the same way but starts and stops. The timing is off too. I need it to take exactly 5 seconds.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 12:47 PM
How does it start and stop, have you even tried it?

Although it DOES need this added to the end:

for i = 1, 55 do
text.TextTransparency = text.TextTransparency + 0.025
wait()
end
Report Abuse
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 01:21 PM
Yes I tried. It's choppy and the timing is off.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 01:34 PM
But its like almost the same thing. How is it choppy..?
Report Abuse
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 02:03 PM
Because it's not the same thing. The timing is off.
Report Abuse
Xeptix is not online. Xeptix
Joined: 14 Mar 2013
Total Posts: 1115
10 Sep 2013 02:21 PM
nise... are you kidding me?...
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
10 Sep 2013 03:03 PM
[ Content Deleted ]
Report Abuse
nise45 is not online. nise45
Joined: 17 Nov 2008
Total Posts: 7002
10 Sep 2013 03:25 PM
Thanks for your response Oysi! The logic thing was never really a problem, but I should fix it for max efficiency. I agree. The thing is that the background for the GUI is already at 60 or so, so I did two of them so that the background and the text faded at (almost) the same rate. Would your solution fix that?

I love your stuff, by the way. c:
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 04:01 PM
@Oysi: If you read my code, you would see I fixed the issue with different loop lengths...
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
10 Sep 2013 04:04 PM
[ Content Deleted ]
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 04:07 PM
But how did I mess up the timing..? Explain.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
10 Sep 2013 04:26 PM
[ Content Deleted ]
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 04:28 PM
...Oops.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
10 Sep 2013 04:51 PM
Well, does RunService count as coroutines? Runservice, if statement and a disconnect.
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
10 Sep 2013 04:56 PM

for i=1,100 do
    if i <= 40 then
        text.BackgroundTransparency = text.BackgroundTransparency + 0.01
    end
    text.TextTransparency = text.TextTransparency + 0.025
    wait(0.05)
end

This _should_ work. Please don't rage if I made a simple or stupid mistake.
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