How to make camera able to zoom and look around?

local E = true
script.Parent.Activated:Connect(function()
	print([==[You 
	Are
	Using
	The
	Camera
	To
	Spy
	On
	Others?
	Shame
	On
	You
	PotatoHead]==])
	E = not E
	if not E then
		cam.CameraType = Enum.CameraType.Fixed
		cam.CameraSubject = nil
		cam.Focus = CFrame.new(mouse.Hit.p)
	else
		cam.CameraType = Enum.CameraType.Custom
		cam.CameraSubject = player.Character.Humanoid
	end
end)

If i click on the ground I can’t look around or zoom in or out. This was not the case a while ago, any help?

1 Like

The camera is fixed which means it cant be moved.

1 Like

You need to make the camera scriptable. For this script it’s fixed.

1 Like

sorry for the long reply, actually i got it working by setting just the camera subject to a part instanced to workspace and setting its cframe and position to the mouse hit position and destroyed the part right after setting the camera subject.

tool.Activated:Connect(function()
	E = not E
	if not E then
		local part = game.ReplicatedStorage.TpCamPart:Clone()
		part.CFrame = CFrame.new(mouse.Hit.p)
		part.Parent = workspace
		cam.CameraSubject = part
		part:Destroy()
	else
		cam.CameraSubject = player.Character.Humanoid
	end
end)

I think you should try with another script. I noticed that you just called a service, but you didn’t give the service a name.

I think i used workspace and player service to locate player,mouse and camera?

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local cam = game:GetService("Workspace").CurrentCamera
....
1 Like

Yes. First call the function, then name it. After that you need to add an event (if player did something, then do that service) Edit: If you need to start this when player joined, add an On Player Entered (join) event

1 Like