Camera view changing doesnt work as intended

I’m trying to make a script that changes player’s camera CFrame then turns back to the original CFrame. But the camera view when resetting back is not like the original.

This is my local script:

local testpart = workspace:WaitForChild("testpart")
local db = false

local cam = workspace.CurrentCamera

local originalcam = cam.CFrame

testpart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChildOfClass("Humanoid") and not db then
		db = true
		
		cam.CameraType = Enum.CameraType.Scriptable		
		cam.CFrame = cam.CFrame * CFrame.new(10000,1000,1000)
		
		task.wait(2)
		
		cam.CFrame = originalcam
		cam.CameraType = Enum.CameraType.Custom

		task.wait(5)
		db = false		
		
	end
end)


In the vid, the view turns back to the side instead of behind the player.

You’re calling cam = workspace.CurrentCamera at the script’s start, so it only runs once as soon as the script begins. (Edit: small clarification, you’re setting the camera’s CFrame equal to originalcam so I slightly misread that. However, the point still applies.)

Instead put it inside the .Touched. Also, be sure to set the CFrame object to originalcam.CFrame and not just originalcam.

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