Making a Gui Slowly turn invisible

I want to make a transition from a Loading screen to a Game menu
All I need is a script to slowly make some parts of the gui go invisible, but I can’t figure it out, I’ve tried this:

while true do
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
task.wait(.01)
Frame.Transparency = Frame.Transparency +.1
end

I want the frame transparency to go up until it reaches 0.8 transparency
but it never closes the loading screen gui so the game menu never shows up and the code glitches.

Note: It DOES transition, but I dont know how to stop the code after 0.8 transparency. it does stop at 0.8 transparency but It won’t close the loading screen gui.

its better to use TweenService

for i = 0, 1, 0.1 do
frame.Transparency = i
task.wait(0.1)
end
1 Like

Change one line in your code:

while Frame.Transparency <= 8 do
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
  task.wait(.01)
  Frame.Transparency = Frame.Transparency +.1
end

Well, that is because you are repeating a loop that is not considering a condition and it is not good practice to write code that way, because it can be overridden in many ways, but the most optimal way is with the TweenService, as follows:

local TweenService = game:GetService("TweenService")
local info = TweenInfo.new(ANIMATION TIME, Other parameters that for this case I don't think you need)

TweenService:Create(Frame, info, {Transparency = 0.8}):Play()

Basicly, first we call the interpolation service, then we create a variable that saves the animation settings that accepts parameters such as time, etc. that you can consult on the roblox page and its documentation

local info = TweenInfo.new()

Finally we call the service and ask it to create an animation in which we first specify the instance to animate, then the tweenInfo.new (which in the code I wrote for you I replaced with the variable that already has it saved) and then a table in which the properties to Animate are specified in this case {Transparency = 0.8} because we want it to reach 0.8, and we reproduce it with the :Play()

Thanks for the help! By the way, how would I do that in reverse? like making a frame less transparent.

TweenService:Create(Frame, info, {Transparency = 0}):Play()

If you want it to be fully visible

I do, but how would I do it with @SubtotalAnt8185’s code?

You can’t. Tweens have more quality and are recommended but come at a cost to a slight bit of memory and performance. You must decide which one you will use.

I recommend that you use the TweenService, just like SubtotalAnt8185 works, but in this the tweenService is more optimizable since you already define up to the time of the Animation, and that cannot be done with the loop, but both work the same

I used your code, but it didn’t work, here’s the code that Im using from your example, also im trying to make it so a text is more visible, not a frame.:

local TweenService = game:GetService("TweenService")
local info = TweenInfo.new()

TweenService:Create(gameMenu.Frame.Button.TextTransparency, info, {Transparency = 0}):Play()

Did I do something wrong?

Yes. You can change the 2 to whatever time you want it to fade.

local TweenService = game:GetService("TweenService")
local info = TweenInfo.new(2)

TweenService:Create(gameMenu.Frame.Button, info, {TextTransparency = 0}):Play()
1 Like

Thanks, It works! I would give you a solve but this discussion is after this topic’s discussion would finish, so I can’t give two solves :frowning:

1 Like

You can unmark the solution button.

Previewing the topic that was solved, I don’t believe a user who stumbles upon this will think that this is the solution:


I think you should mark another reply that gives more information as the solution, thank you.

2 Likes

Done.

Summary

This text will be hidden

Yes, it’s exactly!

I not especificed the parameter from tweenInfo, Sorry :sob: