Help to Change the CameraSubject in a StarterCharacter

I have been working my brain out of my skull for the whole day looking for a way to change the camera subject to a part that isn’t a torso. I couldn’t find anything on YouTube or even the DevForum. I have thought of changing the CameraSubject to the part in StarterCharacter and in workspace, but couldn’t get it. I also thought I could switch it around, dragging the torso with a part, but I couldn’t get the part to move with WASD. Any suggestions/answers to move the part or change the CameraSubject?

image
As you can see there is a torso(the part that will drag the character) and a sphere, the part I want the camera to focus on. The problem is that camera would focus on the torso.

In order to change the CameraSubject, you can utilize a LocalScript that can go into StarterPlayerScripts/StarterCharacterScripts (this might need to be setup differently depending on which one) and create a few different references to start:

local Players = game:GetService("Players") -- Defines the Players service so that...
local player = players.LocalPlayer -- we are able to access the LocalPlayer.

local CurrentCamera = workspace.CurrentCamera -- References the CurrentCamera, which is the Camera that is being used by the player.

Once you have those defined, you can reference the part in the game that you want to swap the CameraSubject to. As an example, assuming the sphere is inside of the Character, you could do the following:

-- This could be inside of a function as well

local Character = player.Character or player.CharacterAdded:Wait() -- References the player's Character/waits for it to load into the game
local sphere = Character:FindFirstChild("NameOfObjectHere") -- References the sphere inside of the Character (replace "NameOfObjectHere" with the name of the sphere)

You can then reference the CurrentCamera and adjust its properties to focus on the sphere:

CurrentCamera.CameraSubject = sphere -- Sets the CameraSubject to the sphere
CurrentCamera.Focus = sphere -- Adjusts the Focus to the sphere (if you're planning on using "Scriptable" CameraType, the Focus will need to be set manually, like this)

Depending on your use case & specific camera angles you’d like to achieve, the CameraType property of the CurrentCamera can be adjusted as well. Take note that if you are using the Scriptable CameraType, more code will be required to update the CurrentCamera’s CFrame on a regular basis.


As I am not very adept with advanced camera manipulation, useful information can be found from the following resources:


Articles


Documentation

2 Likes

Thank you for the comment, I tried but didn’t get it, I have tried a different way of scripting it and it is a step closer.

I do believe it is for one player, so I will work on the all player change tomorrow. Thanks for the suggestion!

2 Likes

So far I have no luck, you can sort of see what I’m going for in The Bloxy Boys by Rdite.

(1) The Bloxy Boys - Roblox

It has bloxy cola being pulled by a part, not a torso and shows that the actual bloxy cola jumps instead of the part. I guess he made the part move through wasd and pull the avatar. I might find a way to do that.

Edit: The part also swims in water, so it has to be a torso or something…