Help with jumpscare cam

I am trying to make a Jumpscare system for me and my friend’s game. And I started off trying to make the player’s camera switch to a part that will function as the jumpscare camera (It’s in a special box with the jumpscare NPC and all of that stuff.

The problem is that I wrote this script that’s going to make the camera switch doesn’t work. I added a print function to check if the script even functions. The script did print the message but it did not switch the camera.
This is the script:

local camera = game.Workspace.CurrentCamera
local cameraPart = game.Workspace.JumpscareBox.JumpscareCam

local function switchCamera()
	camera.CameraSubject = cameraPart
	camera.CameraType = Enum.CameraType.Scriptable
	print("moist")
end

local detectPart = script.Parent

detectPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		switchCamera()
	end
end)


Why would I be writing about this if there was nothing like this on Devforum or the internet overall?

As always there were no errors in the output box except the text that the script printed. It would be nice if I knew why it printed the text but didn’t switch the camera.

Make sure you switch the camera type to Scriptable BEFORE changing any settings. It may also help to use:

Camera.CFrame=CFrame.new(CameraPositionVector3, CameraFocusVector3)

Hope this helps.

1 Like

Like the person above said, you should switch the camera type to scriptable before changing the subject, but I recommend switching the CFrame instead of subject.

local function switchCamera()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = cameraPart.CFrame -- This way, it should copy the orientation and position of the part (rotate the cameraPart if it doesn't orient correctly)
	print("moist") -- lol
end

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