How can I convert a camera from a 2D style to the main style Roblox uses?

So, I’m trying to make it so when the player touches a part, the camera will convert from a 2D like style back to a 3D one, like what Roblox uses for most games by default.

The problem is when said part is touched, the camera just freezes in place. The only thing that changes are the properties and the FOV, but I am unable to move the camera. Most of the other conversations I’ve seen with camera problems have solutions such as to change the CameraType to Custom, or to change the CameraSubject to be the humanoid. Those didn’t work.

Here is my current script so far:

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

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

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

local RunService = game:GetService("RunService")

local function onUpdate()
	if player.Character and player.Character:FindFirstChild("HumanoidRootPart") and Camera2D == true then
		camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,0,60)
	else
		camera.CameraSubject = player.Character.Humanoid
		camera.CameraType = Enum.CameraType.Custom
		camera.FieldOfView = 75
	end
end

workspace.CameraTo3D.Touched:Connect(function(hit)
	if game.Players.LocalPlayer == game.Players:GetPlayerFromCharacter(hit.Parent) then
		Camera2D = false
	end
end)

RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onUpdate)

And here is the video showing the problem.

Some further info, my script is a LocalScript in StarterPlayerScripts.

I believe it’s as simple as doing:

RunService:UnbindToRenderStep("Camera")

Where would I put that? I don’t know much about scripting, some of my script is from the DevForum.

On the line after Camera2D = false.
Example:

workspace.CameraTo3D.Touched:Connect(function(hit)
	if game.Players.LocalPlayer == game.Players:GetPlayerFromCharacter(hit.Parent) then
		Camera2D = false
        RunService:UnbindFromRenderStep("Camera")
	end
end)

Edit: It’s UnbindFromRenderStep, not RunService:UnbindToRenderStep

Just tried it, what happened was the properties just completely didn’t change this time.

Try setting the properties after the new line:

workspace.CameraTo3D.Touched:Connect(function(hit)
	if game.Players.LocalPlayer == game.Players:GetPlayerFromCharacter(hit.Parent) then
		Camera2D = false
        RunService:UnbindFromRenderStep("Camera")
        camera.CameraSubject = player.Character.Humanoid
		camera.CameraType = Enum.CameraType.Custom
		camera.FieldOfView = 75
	end
end)

This also did not work, but it did change the properties this time!

I have tested the exact script that you sent, and it worked perfectly. Do you have any other scripts manipulating the camera?

In fact, I actually do. A LocalScript in StarterCharacterScripts.

local RunService = game:GetService('RunService')

local CameraManipulated = false
local debounce = false

RunService.RenderStepped:Connect(function()
	if CameraManipulated then
		workspace.CurrentCamera.CFrame = workspace.SpikeNPC.Camera.CFrame
		wait(5)
		CameraManipulated = false
	end
end)

workspace.AnimPart.Touched:Connect(function(hit)
	if game.Players.LocalPlayer == game.Players:GetPlayerFromCharacter(hit.Parent) then
		if debounce == false then
			debounce = true
			CameraManipulated = true
			wait(5)
			workspace.CurrentCamera.CFrame = CFrame.new(hit.Parent.HumanoidRootPart.Position) * CFrame.new(0,0,60)
			wait(295)
			debounce = false
		end
	end
end)

This script was meant to activate an animation that moves the camera. The camera is rigged because rig animation is my specialty.

Do you still require this script? If not, I recommend just deleting it, otherwise, if you do still need it. Can you please explain what exactly its needed for, and if you actually touched workspace.AnimPart in that video you posted?

First of all, in the original posts video, I actually touch a part called CameraTo3D, the AnimPart is a completely different trigger.


This video here is what the second script is for.

Okay, so can you check for me one more time, is there any other script that manipulates the camera or does something with the camera in any way?

There are no other scripts that manipulate the camera.

Are you certain that the camera is actually broken? Have you tried rotating the camera with your mouse or arrow keys? If this is the case, how does your character heirarchy look, that might be causing issues.

I have tried using the mouse, and just now tried the arrow keys. They do not work.

Also, what is the hierarchy in this case, is that like the characters rig?

Correct, could you please attach an image of the characters rig? In addition, could you use the find all window, and type in CurrentCamera, and see what pops up. Check if there are any unrecognized scripts.


The item I have highlighted in the explorer is the rig, showing all the instances.

Can you press play and show a picture of the character heirarchy then? It might look different in game.

local function onUpdate()
	if player.Character and player.Character:FindFirstChild("HumanoidRootPart") and Camera2D == true then
		camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,0,60)
	elseif camera.CameraSubject ~= player.Character.Humanoid then
		camera.CameraSubject = player.Character.Humanoid
		camera.CameraType = Enum.CameraType.Custom
		camera.FieldOfView = 75
	end
end

try this.