How to fade out Frame using TweenService

I want to fade out the frame when a Player presses the button “Ok” and then it would play a nice animation using TweenService to fadeout the UI & destroy it.

I tried figuring it out by looking it up everywhere but there was nothing to be found, I managed to use the TweenService animation for my button which works fine and I’ll be linking the code below. I’ll also place a screenshot below that can show how the Frames are placed for a clearer explantion.

Started coding around 1-2 weeks ago just trying to do things on my own now after I spent some time learning the fundamentals of Lua but sometimes I just need some feedback because it does get confusing :sweat_smile:

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local IsHovering = false
local Button = script.Parent

Button.MouseEnter:Connect(function()
	IsHovering = true
	Button:TweenSize(UDim2.new(0.25, 0, 0.3, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.2, true)
end)

Button.MouseLeave:Connect(function()
	IsHovering = true
	Button:TweenSize(UDim2.new(0.2, 0, 0.25, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.2, true)
end)

local Sound = game.SoundService.HoverSound

Button.MouseButton1Click:Connect(function()	
	Sound:Play()
end)

image

TS = game:GetService("TweenService")

TS:Create(Your Frame, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()

Alternate:

TS = game:GetService("TweenService")

local A = TS:Create(Your Frame, TweenInfo.new(1), {BackgroundTransparency = 1})

A:Play()
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.