-
**What do you want to achieve?
I wan’t to achieve an simple zoom-in and out system like Jailbreak or Madcity has.
Refrence: https://gfycat.com/regularbruisedkinkajou -
**What is the issue?
I do not now where to start or how I could start. -
**What solutions have you tried so far?
I’ve did try some methods and tutorials but I can’t find the right solution.
Could you elaborate more on “zoom-in system”? It’s currently a very vague question.
1 Like
They probably just Tween (using TweenService) the Camera’s FieldOfView and the Player’s Character’s Humanoid’s CameraOffset forward (CameraOffset is most possibly used for the 3rd person view).
If you were to say bind this on right click of the Mouse, you could simply use the UserInputType of MouseButton2 in a BindAction of ContextActionService.
Here’s a code example:
--// LocalScript, StarterCharacterScripts
--// Dependencies
local TweenService = game:GetService("TweenService")
local ContextActionService = game:GetService("ContextActionService")
--// Variables
local Character = script.Parent --// Always parented to the character
local Humanoid = Character:WaitForChild("Humanoid")
local Camera = workspace.CurrentCamera
local BindName = "ZoomInBind"
local Info = TweenInfo.new()
--// Tweens, create the tweens for in and out
local Tweens = {
In = {
FOV = TweenService:Create(Camera, Info, {FieldOfView = 60});
Offset = TweenService:Create(Humanoid, Info, {CameraOffset = Vector3.new(0,0,-3)});
};
Out = {
FOV = TweenService:Create(Camera, Info, {FieldOfView = 70});
Offset = TweenService:Create(Humanoid, Info, {CameraOffset = Vector3.new(0,0,0)});
};
}
--// Main function for handling the bind
local function Bind(Name, State)
--// If they started holding MouseButton2
if State == Enum.UserInputState.Begin then
--// Play the ins
Tweens.In.FOV:Play()
Tweens.In.Offset:Play()
--// If they stopped holding MouseButton2
elseif State == Enum.UserInputState.End then
--// Play the outs
Tweens.Out.FOV:Play()
Tweens.Out.Offset:Play()
end
end
--// Bind it to right click (MouseButton2)
ContextActionService:BindAction(BindName, Bind, false, Enum.UserInputType.MouseButton2)
1 Like