I am trying to create a script to move the camera around an object. Everything works fine until I try to give the control of the camera back to the player - I set the camera type to Custom however the camera does not move around the player as it should. Every other camera type (Follow, Track, Attach etc.) will work, just not Custom. What is the problem here.
connection = game:GetService("RunService").Heartbeat:Connect(function() if i < 360 then camera.CFrame = CFrame.new(target.Position) * CFrame.Angles(0, angle, 0) * CFrame.new(0, 10, 50 + 30 * math.sin(math.rad(i/2))) angle = angle + math.rad(0.5) i = i + 0.5 end if i >= 360 and i < 420 then i = i + 1 end if i >= 420 and i < 480 then camera.CFrame = camera.CFrame:lerp(game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(0, 2.5, 10), 0.1) i = i + 0.5 end if i >= 480 then camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid camera.CameraType = Enum.CameraType.Custom -- every other type works fine connection:Disconnect() end end)
I figured it out. The script was called "CameraScript", which means that the default camera control script gets overriden. I solved it by changing the name to something that is not "CameraScript."