How to make a fade-in frame?

So I’m trying to make a fade-in frame that fades once the ProximityPrompt is interacted with. I’m horrible at doing fade in’s and fade outs or stuff like that in general so some help would really be appreciated.
image
My script isn’t working so if anyone could help at all, it would be great.

Edit: When I’m in the game and try to make it visible, nothing appears anyway. When I start with it visible, I can’t make it invisible again.

1 Like

Try this

local Proximity = workspace.inter.ProximityPrompt
local gui = script.Parent
local fog = game.Lighting.FogEnd
Proximity.Triggered:Connect(function()
   for i = 0, 1, 0.01 do
      gui.BackgroundTransparency = i
   end
end)

If this doesn’t work, tell me if there are any errors, what’s working/ not working, etc.

2 Likes

(Above forgot a wait event.)

Here’s another method using the TweenService

local Proximity = workspace.inter.ProximityPrompt
local gui = script.Parent
local fog = game.Lighting.FogEnd

local TweenService = game:GetService("TweenService")
Proximity.Triggered:Connect(function()
	local info = TweenInfo.new(1)--Here's a 1 second tween
	local properties = {BackgroundTransparency = 0}--Will set the BackgroundTransparency to 0
	local tween = TweenService:Create(gui,info,properties)
	tween:Play()--Play animation
end)
2 Likes

Okay so there’s 2 ways to do this:

1: You can try using TweenService instead. This would save up some data usage and it fades in more smoothly

2: You can also try rewriting that script and instead of doing

gui.BackgroundTransparency += 0.01

You can also do

gui.BackgroundTransparency = i

Hope this helped!
SwedishRaptor

1 Like

Thank you for replying everyone! This was my 2nd ever post and didn’t think anyone would reply. I didn’t get notifications for some reason.

Hello! I’m not sure why because it isn’t giving any output but it doesn’t work.

Not sure why, but none of these have worked. It’s probably something wrong on my end since these scripts look very well written.

This is weird, everything is in the correct place.

I was occupied for a bit of time, is it fixed?

If no, have you tried printing in the event to see if it’s even fired?
if it doesn’t print, it’s a problem with your other script, otherwise it’s a problem with the gui.