Text stopped tweening

  1. What do you want to achieve? Keep it simple and clear!

I want to go into Camera Mode and tween the text when I press a key. Then press the same key again and then it will go back to Character Mode.

  1. What is the issue? Include screenshots / videos if possible!

[Current Status Character Mode] there is no errors in the output the text tweened but when I press the key again and go into Camera mode the tween stoppped tweening.

local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local tween = game:GetService("TweenService")
local Cam = game.workspace:WaitForChild("Cam")
local CurrentCam = game.Workspace:WaitForChild("Camera")
local ShowCam = game.ReplicatedStorage:WaitForChild("ShowCamera")
local CamPosition = Vector3.new(31.726, 52.456, -52)
local LookAtPosition = Vector3.new(27.203, 45.491, -52)
local TextLabel = script.Parent:WaitForChild("TextLabel")


UserInputService.InputBegan:Connect(function(Input, chat)
	if Input.KeyCode == Enum.KeyCode.C and not chat then
		if TextLabel.Visible == false then
			TextLabel.Visible = true
			TextLabel.TextScaled = true
			TextLabel.Text = "Press or Click anywhere to go back into Character Mode!"
			local TextGoal = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0.1)
			local TextProperty = {TextTransparency = 1}
			local TextX = tween:Create(TextLabel, TextGoal, TextProperty)
			TextX:Play()
			local TextXGoal = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0.1)
			local TextXProperty = {TextTransparency = 0}
			local TextZ = tween:Create(TextLabel, TextXGoal, TextXProperty)
			TextZ:Play()
			print("tween is playing!")
		end
		CurrentCam.CameraType = Enum.CameraType.Scriptable
		CurrentCam.CFrame = CFrame.lookAt(CamPosition, LookAtPosition)
	else
		CurrentCam.CameraType = Enum.CameraType.Custom
		CurrentCam.CameraSubject = player.Character.Humanoid
		TextLabel.Visible = false
	end
end)

I managed to get it working like so:

local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local TextLabel = script.Parent
local Tweening = false

UserInputService.InputBegan:Connect(function(Input, GameProccessed)
	if GameProccessed then return end
	print(Input.KeyCode)
	if Input.KeyCode == Enum.KeyCode.C then
		Tweening = true
		TextLabel.TextTransparency = 1
		repeat
			TweenService:Create(TextLabel, TweenInfo.new(1), {TextTransparency = 0}):Play()
			wait(1)
			TweenService:Create(TextLabel, TweenInfo.new(1), {TextTransparency = 1}):Play()
			wait(1)
		until not Tweening
	else
		Tweening = false
		TextLabel.TextTransparency = 1
	end
end)

Video example

Thank you bro it worked! I luv you :heart:

Np, good luck with your project.