-
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.
-
What is the issue? Script not working and nothing is in the output.
-
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)