How can I slighty zoom in on a character?

Heyo I have this code for my camera and need some help because I’m not sure how I could zoom in on something.

local Distance = 12
local Xoffset = 0
local Yoffset = 2
local Zoffset = 10

local function CalculateAveragePosition()
	local Total = Vector3.new()
	for _,HRP in pairs(HRPS) do    
		Total += HRP.Position
	end
	return Total / #HRPS
end

--local function CalculateAverageMagnitude()
--	local Total = 0
--	for _,HRP in pairs(HRPS) do    
--		Total += (HRP.Position - StageCam.Position).Magnitude
--	end

--	return Total/#HRPS
--end

for _,HRP in pairs(workspace.Game.Characters:GetDescendants()) do
	if HRP.Name == "HumanoidRootPart" then
		table.insert(HRPS,HRP)
	end
end

--> This code is in a render stepped
local AveragePos = CalculateAveragePosition()
--local AverageMag = CalculateAverageMagnitude() + Zoffset
StageCam.Position = AveragePos
WorkspaceCam.CFrame = StageCam.CFrame * CFrame.new(Vector3.new(Xoffset,Yoffset,Distance))

Heres a video of how it currently looks

And so what I wanna do is when a player does a certain attack I wanna slightly zoom in on them

Lowering the FOV is an effective way to get a zoom effect. Paired with tweening for smooth zooming, you can play around with it. If you want to zoom in on a specific player, you’d also have to change the offset to be on the one player rather than in the middle of the two.

5 Likes

Heyo sorry for the late reply. How would I go about tweening it? Instead of having to do this lol

Modules.Camera.Zoffset = 10
Modules.Camera.Xoffset = -3
wait(0.5)
Modules.Camera.Zoffset = 12
Modules.Camera.Xoffset = 0

just create an intvalue (or a number value) and tween the value of the object

and listen to the on changed event and set the fov as the value