If I set the current camera’s CameraSubject to a part in the workspace, the camera’s position gets set near 0,0,0 in the workspace, and not on the part. Only when I manually change the CameraType does it lock on to the subject.
How do I solve this?
If I set the current camera’s CameraSubject to a part in the workspace, the camera’s position gets set near 0,0,0 in the workspace, and not on the part. Only when I manually change the CameraType does it lock on to the subject.
How do I solve this?
CameraSubject is only used for CameraType Custom, Attach, Watch, Follow, Track. If it is set to Scriptable, it does nothing.
The type is custom
In order to change the position of the camera to a part I would change the CameraType to “Scriptable” and change the CameraSubject to the part.
When you want the camera to go back to the player then change the CameraType to “Custom” and the CameraSubject to their humanoid.
That doesn’t work.
Here is my code:
local Workspace = game.Workspace
local Camera = Workspace.CurrentCamera
Workspace:WaitForChild("Ball")
Workspace:WaitForChild("Camera")
Workspace:WaitForChild("Brick")
local Ball = Workspace.Ball
Camera.CameraType = "Custom"
Camera.CameraSubject = Ball
Can anyone help?
You’ll want to do something like this:
-- Defining the variables
local CurrentCamera = workspace.CurrentCamera
local Ball = workspace.Ball
-- Code
CurrentCamera.CameraType = "Scriptable"
CurrentCamera.CameraSubject = Ball
CurrentCamera.CFrame = Ball.CFrame -- This attaches the Camera's CFrame to the ball
If you want to have the camera look at the player later, add:
wait(However long you want to wait in seconds) -- e.g. wait(0.5)
CurrentCamera.CameraSubject = Player.Character.Humanoid -- Assumes you have "Player" already defined
CurrentCamera.CameraType = "Custom"
In addition, you should have this in a LocalScript under any of the following services:
Still does not work. I have another script which destroys the player immediately, so that the camera focuses on the ball, which will be a “custom character”. The camera is now focusing on the floating humanoid of the destroyed character. ( I’m not returning the camera to the character ever )