Is it possible to change the camera view every time a player teleports with proximity?

I recently made a code to change the the view of the camera as if it were 2D
but i was curious if it were possible that the number of the FOV or camera Cframe changes every time i teleport using the proximitypromt.

so far i tried by creating this script but it has no affect
its a local script and its placed under a proximitypromt
the idea is that the player uses it and teleports. But while teleporting the FOV and Cframe value change so idk if i was in the right with this code

ocal player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 40

local function onPromptTriggered()
    camera.FieldOfView = 60

    camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0, 0, 10)
end

script.Parent.Triggered:Connect(onPromptTriggered)

1 Like

You need to make the camera type Scriptable when you want to change it, but remember to change it back when you want to give the player control back.

1 Like

as of now the main normal camera script is

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 40

game:GetService('RunService').Stepped:Connect(function()
	camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,0,30)
end)

but i want to know in the script i added before if it were possible to change it

You can change the camera view at anytime … why would this moment be any different …

1 Like

i mean i want to change it as the player presses E on the proxiimity to teleport (a script i made) and as they go to this new location the FOV/Cframe value changes with it