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

Previous Thread :: Next Thread 
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:17 AM
Unexpected symbol near ')'

for _, v in pairs(game.Workspace:GetChildren()) do if v:IsA("Part") then coroutine.resume(coroutine.create(function(a) for i = 0, 1, 0.01 do v.Transparency = i wait(0.01) end))) end end


Easier formatted:

for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
coroutine.resume(
coroutine.create(function()
for i = 0, 1, 0.01 do v.Transparency = i wait(0.01) end)
)) end end
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
03 Jul 2014 04:21 AM
that means there are an incorrect number of )s

in this case, iirc, you have too many.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:22 AM
this fixes a bit more i think


for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
coroutine.create(coroutine.resume(function()
for i = 0, 1, 0.01 do
v.Transparency = i wait()
end
end)
end)
end)
end
end


Error in script: ')' expected near 'end'
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
03 Jul 2014 04:22 AM
a ) is in the incorrect place
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:23 AM
for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
coroutine.create(coroutine.resume(function()
for i = 0, 1, 0.01 do
v.Transparency = i wait()
end -- FOR i LOOP
end) -- FUNCTION
end) -- RESUME
end) -- CREATE
end -- IF STATMENT
end -- FOR LOOP
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
03 Jul 2014 04:28 AM
for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
coroutine.create(coroutine.resume(function()
for i = 0, 1, 0.01 do
v.Transparency = i wait()
end -- FOR i LOOP
end)) -- FUNCTION right here
end) -- RESUME
end) -- CREATE
end -- IF STATMENT
end -- FOR LOOP

Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:32 AM
for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
coroutine.create(coroutine.resume(function()
for i = 0, 1, 0.01 do
v.Transparency = i wait()
end end))
end) end)
end end


unexpected symbol near ')'
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
03 Jul 2014 04:35 AM
sorry it's late

for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
coroutine.create(coroutine.resume(function()
for i = 0, 1, 0.01 do
v.Transparency = i wait()
end end))
end end
end end

the last two were not needed (they already had (s
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
03 Jul 2014 04:35 AM
also coroutine.create does not require an end
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:43 AM
Final ( working ):

for _, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
coroutine.resume(coroutine.create(function()
for i = 0, 1, 0.01 do
v.Transparency = i wait()
end end))
end end



Thanks! :D
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 04:45 AM
You could do that without a coroutine...

Good practice, though (although I recommend you avoid coroutines if possible)
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:46 AM
How so?

It will wait constantly.
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
03 Jul 2014 04:51 AM
you could technically use the Spawn() function but it's basically the same thing as a coroutine
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 04:52 AM
local c = workspace:GetChildren()

for v = 1, 100 do
for k = 1, #c do
if c[k]:IsA"BasePart" then
c[k].Transparency = v/100
end
end
end
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 04:53 AM
Forgot a wait, but you can manage to add one yourself just before the last end,
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:58 AM
-- no output, not even making transparent and dont know how to make it wait on RenderStepped.



for _, Gui in pairs(LoadingFrame:GetChildren()) do

if Gui:IsA("GuiObject") then

coroutine.resume(coroutine.create(function()

for i = 0, 1, 0.01 do

Gui.BackgroundTranparency = i

if Gui:IsA("TextLabel") then

Gui.TextTransparency = i

end
-- RenderStepped here.
end

end))

end
end
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 05:01 AM
Add some prints and tell us what you get.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 05:01 AM
Frame ( LoadingFrame )
-Another Frame
-Another Frame
-TextLabel
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 05:03 AM
Called a function too, didnt wait till it was finished - just continued the script.



Anyway,

A
B
C
D
E
B
C
D
E
B
C
D
E

function FadeLoadingFrame()
print("A")
for _, Gui in pairs(LoadingFrame:GetChildren()) do
print("B")
if Gui:IsA("GuiObject") then
print("C")
coroutine.resume(coroutine.create(function()
print("D")
for i = 0, 1, 0.01 do
print("E")
Gui.BackgroundTranparency = i

if Gui:IsA("TextLabel") then
print("F")
Gui.TextTransparency = i

end

end

end))

end
end

end

Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 05:04 AM
And the transparency won't become 1?
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 05:07 AM
Not at all.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
03 Jul 2014 05:12 AM
print("E", Gui)
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