Camera Manipulation Not Working

  1. What do you want to achieve? I want when a player trigger a ProximityPrompt the player camera change to the direction of the part that it is facing.

  2. What is the issue? Script not working and nothing is in the output.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? (Yes)

Hello!
So I want to make when a player trigget the ProximityPrompt and player camera changes to the direction of the part it is facing for 5 seconds.
It is a bit same as a menu camera, but nothing seems to work. I am still a beginner and I did not find any solutions online.

Heres the script:

local part = game.Workspace.IMPORTANT.CameraPart
local proximityPrompt = script.Parent

local camera = game.Workspace.CurrentCamera
local defaultCameraCFrame = camera.CFrame
local focusTime = 5 

local function onFocus()
	local partPosition = part.Position
	local newCameraCFrame = CFrame.new(partPosition + Vector3.new(0, 5, -10), partPosition) -- Adjust the camera position to focus on the part
	camera.CFrame = newCameraCFrame
	wait(focusTime)
	camera.CFrame = defaultCameraCFrame 
end

proximityPrompt.Triggered:Connect(onFocus)
2 Likes

It seems like the script isn’t parented to the ProximityPrompt? Since the arrow is closed.

Oh sorry, I’ve sent the wrong pic. The script is placed in the correct place.

Put a print on the first line of the function “onFocus” to make sure that it is firing, let me know if it is firing the print statement.

It could be that you’re not changing the camera type of the camera, thus you can’t do anything with the camera. You should set it from Custom to Scriptable instead. Here’s an example of how it would work:

-- THIS ONLY WORKS IN A LOCAL SCRIPT!

local Camera = game.Workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable

-- do your stuff here
1 Like

Oh, Thank You it works now!
Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.