Camera script doesn't really want to work

So I kinda have a script that wait till a frame backgroundtransparency is 1 to work.
Instead , It doesn’t work and I don’t know the problem.

image
Inside of it :

local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera

local cutsenetime = 7

local tweenInfo = TweenInfo.new(
	cutsenetime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

function tween(part1,part2)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = part1.CFrame

	local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
	tween:Play()

	wait(cutsenetime)

	camera.CameraType = Enum.CameraType.Custom
end

if script.Parent.ScreenGui.TextLabel.BackgroundTransparency == 1 then
	tween(game.Workspace.Test1,game.Workspace.Test2)	
end

Any help would be appreciated

if it does not give error then the problem should be this

if script.Parent.ScreenGui.TextLabel.BackgroundTransparency == 1 then
	tween(game.Workspace.Test1,game.Workspace.Test2)	
end

I suggest you try this first

local run = game:GetService("RunService")

run.RenderStepped:Connect(function()
      if script.Parent.ScreenGui.TextLabel.BackgroundTransparency == 1 then
	   tween(game.Workspace.Test1,game.Workspace.Test2)	
      end
end

if this one works out then it’s up to you stop calling the tween many times

It doesn’t really tween like. The screen is a bit glitched. I don’t have a video to show so you could try and see.

then we can’t fix the problem if you can’t show the exact problem

I’ve mentioned that you could try and see. The camera script was working well before I added

if script.Parent.ScreenGui.TextLabel.BackgroundTransparency == 1 then
	tween(game.Workspace.Test1,game.Workspace.Test2)	
end

I want the camerascript to works when the TextLabel BackgroundTransparency is 1 and even the title says.