Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make it so that after the press of a button, the screen fades into the game?

I'm new to scripting, so how can I make it so that when a player closes a screen GUI welcoming them into the game, the whole screen fades out and into the game?

  1. button = script.Parent
  2. num = 85
  3. while true do
  4.      **for** i = 1, num **do**
    
  5.                  button.BackgroundTransparency = 0.5+i/num/2
    
  6.                  **wait**()
    
  7.     **end**
    
  8.     **for** i = 1, num **do**
    
  9.                  button.BackgroundTransparency = 1 - i/num/2
    
  10.                **wait**()
    
  11.   **end**
    
  12. end

The script I currently have is underneath: StarterGUI > ScreenGUI > Frame > TextButton > LocalScript. Is this wrong? It seems to only be working on the button, not the whole screen, and it is in a loop. How can I fix this so that the whole screen fades in once the button is pressed?

1 answer

✓ Accepted answer

This is really close! You just made one tiny mistake. You're telling the script's parent to fade, which is just the button, when you should be telling the script's parent's parent, if you want the whole thing to fade.

So, anywhere you're saying button.BackgroundTransparency = x should become button.Parent.BackgroundTransparency = x.

Keep in mind however that any text elements, pictures, etc you have on the GUI will not fade with this script in its current state, as all you're doing is telling the opaque background to disappear, but not all the things on top of it. If this is going to be a problem for you, you'll have to unfortunately set each element of the GUI to fade, i.e. button.TextTransparency = 0.5+i/num/2, button.Parent.ImageLabel.ImageTransparency = 0.5+i/num/2, and so on.

As an added note, you should also either remove() the whole ScreenGUI or make sure Enabled = false after you make it fade out.

Hope this helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.