How to make gun camera zoom?

Hello there,
I recently made a simple gun but I need when you press left mouse button it will zoom the camera like in this images, (All images are screenshoted from game The Wild West)

Thanks for any help!

1 Like

You can get the player camera and reduce field of view!:hamburger:

1 Like

No, You don’t get it I wanna ofset it from camera like shift lock

There is only one image at your post, hard to understand what you mean. :thinking:
If you want to change the camera subject or offset, they can be set the same way directly from camera properties.

Well I did this script and I get this

Mouse.Button2Down:Connect(function()
	if Equipped == true then
		local tween = game:GetService("TweenService"):Create(workspace.CurrentCamera,TweenInfo.new(1),{FieldOfView = 50})
		tween:Play()
		local tween1 = game:GetService("TweenService"):Create(Player.Character.Humanoid,TweenInfo.new(1),{CameraOffset = Vector3.new(2,0,0)})
		tween1:Play()
		Player.CameraMode = Enum.CameraMode.LockFirstPerson
	end
end)

-- UnZoom
Mouse.Button2Up:Connect(function()
	if Equipped == true then
		local tween = game:GetService("TweenService"):Create(workspace.CurrentCamera,TweenInfo.new(1),{FieldOfView = 70})
		tween:Play()
		local tween1 = game:GetService("TweenService"):Create(Player.Character.Humanoid,TweenInfo.new(1),{CameraOffset = Vector3.new(0,0,0)})
		tween1:Play()
		Player.CameraMode = Enum.CameraMode.Classic
	end
end)

This what I get

2 Likes

Humanoid.CameraOffset is what you’re probably looking for. Combine it with a little change of your FoV and you’ll get an appealing result.

You’ll need to address the right mouse button (MouseButton2Down I believe), then do if MouseButton2Down, adjust the camera offset with Humanoid.CameraOffset. This creates a toggle zoom I believe, not too sure about that. You can also look in gun kits in the Toolbox for ideas.

MouseButton2Down is used for gui buttons, and Button2Down is used for mouse

1 Like

Ah yes I see, thanks for correcting me.

mouse.Button2Down:Connect(function()

	

	local camera = game.Workspace.CurrentCamera

	

	camera.FieldOfView = 40

	

end)



mouse.Button2Up:Connect(function()

	

	local camera = game.Workspace.CurrentCamera

	

	camera.FieldOfView = 70

	

end)

end)

2 Likes

Let me help with some of my own code:

first keep in mind u can use this code wherever u want u can set the keycode(key in the keyboard to whatever you want but if you looking to aim let it like this)

STEPS:

First create a variable that says something like

local aiming = false

then just you might wanna keep in mind that i will teach you to use this zoom in effect by CFrames So lets just go like this

  if aiming then
		local tween = Tween:Create(cam, aim_tween, {FieldOfView = 70/1.2})	
		tween:Play()
		aimcf = aimcf:Lerp(weaponData.AimCFrame, 0.2)
	else
		local tween = Tween:Create(cam, aim_tween, {FieldOfView = 70})	
		tween:Play()
		aimcf = aimcf:Lerp(CFrame.new(), 0.1)
	end

when we have these lines of code in just use a module script or where all your weapons settings are and create a cframe value something like

[ModuleName].AimCFrame = CFrame.new(any value that you might use to make it look good)

and forgot to say that you need to create a variable on the local script that state the aim_tween

local aim_tween = TweenInfo.new(
0.1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)

hit me up if it doesnt work and ill try to help you!, give a like if this answer was useful, have a great day

thanks for your guide ^^ :grinning: