How do i make a camera effect as i get closer

Is there a way I can make it so the camera zooms in more and more as close it gets to the object and the starts going back to normal if I go back away from the object.
image

https://gyazo.com/2544937e1ca21563079fa4474330aa04

Is this what you’re trying to achieve? Here’s the script I wrote which zooms in/zooms out on a part when the player’s character gets closer to the part/further away from the part respectively.

local run = game:GetService("RunService")
local tweens = game:GetService("TweenService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")

local camera = workspace.CurrentCamera

local part = workspace:WaitForChild("Part")

local function onRenderedFrame()
	local _, visible = camera:WorldToScreenPoint(part.Position)
	if visible then
		local distance = player:DistanceFromCharacter(part.Position)
		if distance < 50 then
			local unit = (head.Position - part.Position).Unit
			camera.CFrame = CFrame.lookAt(head.Position + unit * (distance * 0.25), part.Position)
		end
	end
end

run.RenderStepped:Connect(onRenderedFrame)
2 Likes

I tried it but tbh it didn’t really work plus there was no error in output

I provided a gif which shows it works.

Should it be a local or server script?

Local script inside StarterCharacterScripts and a BasePart instance named “Part” is required.