Can't achieve the desired effect manipulating camera's CFrame

So, to get more specific, I want my camera to be looking at my clone’s right/left arm with the “position” my camera already has, like this.


To further describe what “position” is, in the picture below, my camera seems to also be looking at my clone’s right arm, however its “position” is different than the “position” my camera previously had.

I’m guessing what I need to do is only change my Camera’s RightVector so that it looks at my clone’s arm, but I don’t know how to do that.

Ok, that makes more sense. So you want the camera to switch over to your clone, and be rotated as if your clone had aimed their camera the exact same way relative to their character?

Sorry, I’m not sure I follow. I think my last post explained it well.

-- Get the camera
local Camera = workspace.CurrentCamera

-- Make a simple function
local function LookAt(part)
    -- Make it manipulable
    Camera.CameraType = Enum.CameraType.Scriptable
    -- Look at it using CFrame.lookAt
    Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, part.Position)
    -- Allow other scripts to manipulate it again
    Camera.CameraType = Enum.CameraType.Custom
end

-- Now, you can hook the following up to whatever you want:
LookAt(workspace.heavenswilI['Left Arm'])

(lag from the cursor is a roblox bug)

You could also use tweens to smooth it, like this:

local function LookAt(part)
    Camera.CameraType = Enum.CameraType.Scriptable
    local tween = game.TweenService:Create(
        Camera, 
        TweenInfo.new(1), 
        {CFrame = CFrame.lookAt(Camera.CFrame.Position, part.Position)}
    )
    tween:Play()
    tween.Completed:Connect(function()
        Camera.CameraType = Enum.CameraType.Custom
    end)
end

I would like to help a little too, but, tbh its a little confusing to understand the position, target and behaviour of the camera you want to achieve, I would ask for a drawing too as @azqjanna said :grin:

2 Likes

I rewatched the first video. You want your camera to toggle between between pointing directly at the clone’s left arm, to their right? What places the camera on the left arm initially? Or is the goal just to make the player camera look at one arm or the other, alternating each time the function runs?

Hi, thanks for taking the time. This was the output of the code, it’s not what I have in mind. Only at the end does it look at my clone’s right arm like I want it to (refer to my first post)

Yeah, the goal is to have the camera transition between looking at my clone’s right arm and left arm like in the first video.

Hey. Yeah, no problem. Would you mind telling me what you want me to draw? I did my best explaining in my earlier post, so I don’t really know what to draw.

That is probably happening due to your character and the clone having the same name.

You can fix this by renaming the clone something random, and changing the “DisplayName” property of its humanoid.

Edit: Looking at the original code, I’m assuming you just put this into the while loop. You shouldn’t do that, instead, use the tween method I showed above.

1 Like

You cannot do this with the default shift-lock script, you have to write your own over-the-shoulder camera system.

No.

I’m not sure where you got the idea to change Humanoid’s DisplayName, but that won’t change anything either as I don’t reference the clone by it.

The tween just breaks my camera.

Hi. Why can’t I do it with the default shift-lock script?

As you know shift-lock has always put the camera above the right shoulder, it’s just how Roblox decided it should work, so even if you change the camera’s CFrame, the shift-lock script that manages the camera will override your changes. You’d have to fork the shift-lock camera module to make it compatible to whatever you want to achieve, it’s located somewhere under PlayerModule (StarterPlayerScripts, you have to test the game for it to appear). Or, alternatively you can use an open-sourced module made by another user (this should work), or you can just write the system yourself using CFrame.lookAt and the camera’s lookVector.

I don’t think that’s accurate. As you can see below, my friend made a script that focuses the camera on your right arm.

Yes. But it’s not done while shift-lock is on. Unless he forked the module script.

What do you mean? It’s done while shift-lock is on, and he didn’t fork the module script or whatever.

Well, to my knowledge it is not possible to override the behavior from shift-lock. Why don’t you ask an explanation to your friend then?

Sorry, I didn’t get the chance to reply. I don’t ask my friend because I don’t want to bother him.

Bump, haven’t found a solution.