|
| 11 Aug 2014 04:43 PM |
I have a function that is supposed to make all the elements in a GUI fade out, but it doesn't do anything. The hierarchy is below. I have noticed that there is an infinite loop when it gets to the Choices frame. The function is below the hierarchy.
Hierarchy: ---------------
~MainMenu (ScreenGui) >Sound (Sound) >LocalScript (LocalScript) [Contains the Fade function] >Settings (Frame) -SettingToggle (ImageButton) -ToolTip (TextLabel) >Options (Frame) -Load (TextButton) -Party (TextButton) +Choices (Frame) =Create (TextButton) =Join (TextButton) -Start (TextButton) >Logo (ImageLabel)
Fade Function: ----------------------
function fade(parent,dir,speed) if dir == 1 then for i=0,1,math.abs(speed) do for _,obj in pairs(parent:GetChildren()) do print("Current:",i,obj:GetFullName()) if obj.ClassName == "Frame" then if obj.Style ~= Enum.FrameStyle.Custom then obj.Style = Enum.FrameStyle.Custom end obj.BackgroundTransparency = i elseif obj.ClassName == "ImageLabel" then obj.ImageTransparency = i elseif obj.ClassName == "TextButton" then if obj.Style ~= Enum.ButtonStyle.Custom then obj.Style = Enum.ButtonStyle.Custom end obj.BackgroundTransparency = i end if #obj:GetChildren() > 0 then fade(obj,dir,speed) end if i >= 1 then obj.Visible = false end end wait(speed) end end end |
|
|
| Report Abuse |
|
|
Alexware
|
  |
| Joined: 07 May 2010 |
| Total Posts: 661 |
|
|
| 11 Aug 2014 04:45 PM |
2manywords|is mind blown
Ok so, try a while true do obj.BackgroundTransparency=obj.BackgroundTransparency - PutSpeedHere( 0.01 = best quality, 1 = lolno. ew.) |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2014 04:51 PM |
| A while true loop won't work for what I'm trying to do. I want to eliminate the infinte loop. |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
| |
|
|
| 11 Aug 2014 04:55 PM |
That's what I am using...
The issue is occuring at the recursive function. |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Aug 2014 05:02 PM |
| you have a bad life for not helping |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2014 05:04 PM |
| @dueling; True, but not related to the issue. |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Aug 2014 05:21 PM |
| Let's get back on topic. Any idea on how to stop the infinite loop? |
|
|
| Report Abuse |
|
|
Tripane
|
  |
| Joined: 03 Jun 2011 |
| Total Posts: 11432 |
|
| |
|
|
| 11 Aug 2014 05:30 PM |
| 'speed' is one of the arguments. When I call the function, it is set to 1/30. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 11 Aug 2014 08:42 PM |
I fixed the infinite loop, but only the frames are fading out. Everything else in the GUI is still visible. This is my current function:
function fade(parent,dir,speed) if dir == 1 then for i=0,1,math.abs(speed) do for _,obj in pairs(parent:GetChildren()) do print("Current:",i,obj:GetFullName()) if obj:IsA("GuiObject") then if obj.BackgroundTransparency ~= 1 then if obj.ClassName == "Frame" then if obj.Style ~= Enum.FrameStyle.Custom then obj.Style = Enum.FrameStyle.Custom end obj.BackgroundTransparency = i elseif obj.ClassName == "ImageLabel" then obj.ImageTransparency = i elseif obj.ClassName == "ImageButton" then obj.ImageTransparency = i elseif obj.ClassName == "TextButton" then if obj.Style ~= Enum.ButtonStyle.Custom then obj.Style = Enum.ButtonStyle.Custom end obj.BackgroundTransparency = i end end end if i == 1 then if #obj:GetChildren() == 0 then print(obj.Name.." is done!") obj.Visible = false else fade(obj,dir,speed) end end end wait(speed) end end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Aug 2014 09:30 PM |
Wow... You're making that a lot more complicated than it needs to be.
If you look closely, I don't give a crap. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|