How do I clean up this fade in and out script?

Hello! I’m aware that theres probably a really easy solution but i’m trying to make this script not look so bulky, is there anyway to automate these?

		Block.Transparency = 0.6
		wait(0.1)
		Block.Transparency = 0.7
		wait(0.1)
		Block.Transparency = 0.8
		wait(0.1)
		Block.Transparency = 0.9
		wait(0.1)
		Block.Transparency = 1
		wait(5)
		Block.Transparency = 1
		wait(0.1)
		Block.Transparency = 0.9
		wait(0.1)
		Block.Transparency = 0.8
		wait(0.1)
		Block.Transparency = 0.7
		wait(0.1)
		Block.Transparency = 0.6
		wait(0.1)
		Block.Transparency = 0.5

Block is script.Parent

Use tweens.

local Block = script.Parent
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out
)

local tweenFadeOut = TweenService:Create(Block, tweenInfo, {Transparency = 1})
local tweenFadeIn = TweenService:Create(Block, tweenInfo, {Transparency = 0})

tweenFadeOut:Play() -- fade out
tweenFadeOut.Completed:Wait() -- wait for it to finish

tweenFadeIn:Play() -- fade in
tweenFadeIn.Completed:Wait()

local TweenService = game:GetService(“TweenService”)
local part = workspace:WaitForChild(“Block”) --your block

local tweenInfo = TweenInfo.new(
1, --seconds to animate
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0, – loop forever – how many loops you want of fading in and out
true, – reverse after each play – true if you want it to reverse, example 0 transparency to 1 then back to 0
0 – no delay – delay between reverse
)

local tween = TweenService:Create(part, tweenInfo, {Transparency = 1}) – amount you want to go down to
tween:Play()

local TweenService = game:GetService(“TweenService”)

local tweenInfo = TweenInfo.new(
	1, -- Seconds to animate
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,
	0, -- No repeats
	true, -- Reverse back to initial value after finishing tween to transparency=1
	5 -- 5 second delay between reverse
)

local tween = TweenService:Create(Block, tweenInfo, {
	Transparency = 1 -- End goal
})
tween:Play()

Here’s the same thing but formatted correctly. (Also recommended to use task.wait() instead of wait() which is pretty much deprecated at this point)

This helped out a bunch, Thank you!