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.
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
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?
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.
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.
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