Shouldn't be a hard fix

I have a script that uses a cut scene as a menu screen. I want to make it so that when someone clicks q the camera switches back to the player’s view. Though it doesn’t work.

local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera

local cutscenceTime = 5

local tweenInfo = TweenInfo.new(
	cutscenceTime,
	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(cutscenceTime)
	


	local UserInputService = game:GetService("UserInputService")

	UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
		if input.UserInputType == Enum.UserInputType.Keyboard then
			if input.Keycode == Enum.KeyCode.Q then
				camera.CameraType = Enum.CameraType.Custom
			end
		end
	end)




end

wait(2)

tween(game.Workspace.Home1,game.Workspace.Home2)
3 Likes
local TweenService = game:GetService("TweenService")
local camera = game.Workspace.Camera
local cutscenceTime = 5
local tweenInfo = TweenInfo.new(
	cutscenceTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local Player = game.Players.LocalPlayer -- NEW PART --

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(cutscenceTime)
	
	local UserInputService = game:GetService("UserInputService")

	UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
		if input.UserInputType == Enum.UserInputType.Keyboard then
			if input.Keycode == Enum.KeyCode.Q then
				camera.CameraType = Enum.CameraType.Custom
				camera.CameraSubject = Player.Character.Humanoid -- NEW PART --
			end
		end
	end)
end

wait(2)

tween(game.Workspace.Home1,game.Workspace.Home2)
1 Like

Thanks for your help! Though the script doesn’t work.

I believe this is in a local script? If it is, you should use workspace.CurrentCamera as your camera.

1 Like

Where would I put that in? (I put it as the subject and it didn’t work)

-- Update --

local TweenService = game:GetService("TweenService")
local camera = game.Workspace.Camera
local cutscenceTime = 5
local tweenInfo = TweenInfo.new(
	cutscenceTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local Player = game.Players.LocalPlayer -- NEW PART --

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(cutscenceTime)
	
	local UserInputService = game:GetService("UserInputService")

	UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
         if input.Keycode == Enum.KeyCode.Q then
			camera.CameraType = Enum.CameraType.Custom
			camera.CameraSubject = Player.Character.Humanoid -- NEW PART --
      	end

	end)
end

wait(2)

tween(game.Workspace.Home1,game.Workspace.Home2)
1 Like

Is this a local script or a server script?

1 Like

Still doesn’t work. And what do you mean by new part?

local script


Did you find any errors or prints debugging?

To know what I added

30This text will be blurred

There is an error message,

Keycode is not a valid member of InputObject “InputObject” line 27

Im using Rami’s script, and there is an error message

Keycode is not a valid member of InputObject “InputObject”

@Rami_XD1 @ItzMeZeus_IGotHacked

Any ideas on what the issue is all about?

yeah just a second i will fix that

1 Like
local TweenService = game:GetService("TweenService")
local uis = game:GetService("UserInputService")

local camera = game.Workspace.Camera
local cutscenceTime = 5
local tweenInfo = TweenInfo.new(
	cutscenceTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local Player = game.Players.LocalPlayer 


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(cutscenceTime)

	uis.InputBegan:Connect(function(input)
		if input.KeyCode == Enum.KeyCode.Q and uis:GetFocusedTextBox() == nil then	
			camera.CameraSubject = Player.Character.Humanoid 
			camera.CameraType = Enum.CameraType.Custom
		end
	end)
end

wait(2)

tween(game.Workspace.Home1,game.Workspace.Home2)
1 Like

Eyyyyyy it works! Tysm!


2 Likes