How to make cam follow head and not needing to press e multiple times just to catch up

script:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local ts = game:GetService("TweenService")
local cam = workspace.CurrentCamera
local uis = game:GetService("UserInputService") 
uis.InputBegan:Connect(function(input,ispooping)
	if ispooping then return end
	if input.KeyCode == Enum.KeyCode.E then
		cam.CameraType = "Scriptable"
		cam.CFrame = head.CFrame
	end
end)

vid:

What is the behaviour you’re trying to achieve? Are you trying to create a First Person Toggle with E?

1 Like

no more like a cutscene in first person and walking also this is just part 1

local Valid = false
uis.InputBegan:Connect(function(input,ispooping)
	if ispooping then return end
	if input.KeyCode == Enum.KeyCode.E then
                cam.CameraType = "Scriptable"
                Valid = true 
                 while Valid == true do
		     cam.CFrame = head.CFrame
                     wait(Amount) 
end
	end
end)

uis.InputEnded:Connect(function(input,ispooping)
	if ispooping then return end
	if input.KeyCode == Enum.KeyCode.E then
		cam.CameraType = "Fixed"
		cam.CameraSubject = urPlayer
Valid = false
	end
end)
1 Like
local run = game:GetService("RunService")
local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local head = character:WaitForChild("Head")
local camera = workspace.CurrentCamera

local toggle = false
local connection

userInput.InputBegan:Connect(function(input, processed)
	if processed then return end
	
	if input.KeyCode == Enum.KeyCode.E then
		toggle = not toggle
		if toggle then
			camera.CameraType = Enum.CameraType.Scriptable
			connection = run.RenderStepped:Connect(function()
				camera.CFrame = head.CFrame
			end)
		else
			if connection then
				if connection.Connected then
					connection:Disconnect()
				end
			end
			camera.CameraType = Enum.CameraType.Custom
			camera.CameraSubject = humanoid
		end
	end
end)

Assuming you wanted a toggle.