How would I reverse my 'for i = 1,100" script?

okay let me explain
here is my script:

local frame = script.Parent
local plr = game.Players.LocalPlayer
script.Parent.Parent.Enabled = false
plr.Chatted:Connect(function(msg)
	if msg == "mr. kitty" or "kitty" then
script.Parent.Parent.Enabled = true

for i = 1,100 do
	frame.BackgroundTransparency -= 0.05
			wait (0.01)
		end
		end
end)

and it makes a frame on screen go from 0 transparency to 1 after a word is said in chat (which works perfectly fine.) now i’m trying to make it go from 1 to 0 transparency right after the first thing finishes like a blink. ive tried adding a wait and then doing ‘+= 0.05’ and it doesn’t work. can somebody help? thx

do for i=100, 1, -1 since the third option is the change amount (default is 1)

	frame.BackgroundTransparency -= 0.05
			wait (0.01)
		end
		end
end)

like this?

You can use TweenService for this:

local tweenInfo = TweenInfo.new(
      1, -- the length of time it takes to complete the tween
      Enum.EasingStyle.Sine, -- the tweening EasingStyle (the way it transitions)
      Enum.EasingDirection.InOut, -- the tweening EasingDirection (the direction that it tweens in)
      0, -- how many times it should repeat itself
      true, -- **this is what you want**; when the tween is finished, it'll go in reverse back to the default (original) value
      0 -- the delay in which the tween will take (How long the code will wait before playing the tween)
)

local tween = game:GetService("TweenService"):Create(
      frame, -- the object to be tweened
      tweenInfo, -- the tween information to read from (the thing that was previously defined)
      {
           BackgroundTransparency = 0 -- the property to be tweened and its end value
      }
)

tween:Play() -- plays the tween

Article to explain and show more examples using TweenService

oh okay let me mess around with this thanks

local frame = script.Parent
local plr = game.Players.LocalPlayer
script.Parent.Parent.Enabled = false
plr.Chatted:Connect(function(msg)
	if msg == "kitty" then
script.Parent.Parent.Enabled = true

		local tweenInfo = TweenInfo.new(
			1, -- the length of time it takes to complete the tween
			Enum.EasingStyle.Sine, -- the tweening EasingStyle (the way it transitions)
			Enum.EasingDirection.InOut, -- the tweening EasingDirection (the direction that it tweens in)
			0, -- how many times it should repeat itself
			true, -- **this is what you want**; when the tween is finished, it'll go in reverse back to the default (original) value
			0 -- the delay in which the tween will take (How long the code will wait before playing the tween)
		)
		
		local tween = game:GetService("TweenService"):Create(
		frame, -- the object to be tweened
		tweenInfo, -- the tween information to read from (the thing that was previously defined)
		{
			BackgroundTransparency = 0 -- the property to be tweened and its end value
		}
		)

		tween:Play() -- plays the tween
		
	end
end)

so here is what i have, it’s giving an error for the
’local tween = game:GetService(“TweenService”):Create(
frame,'

part which is
"MultiLineStatement: (18,3) Statement spans multiple lines; use indentation to silence"

You can either indent the code line on line 18 until the warning goes away or delete the indentions and put them all on one line like this:

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, true, 0)
local tween = game:GetService("TweenService"):Create(frame, tweenInfo, {BackgroundTransparency = 0})

tween:Play()

works great, thank you so muchhhh