Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a camera follow a person but still be able to move the camera?

Asked by
Noculus 25
10 years ago

I was able to get the camera to follow a person, but the camera position doesn't move. Just the angle. I am using a hopperbin tool. And this is a localscript which is a direct child of the hopperbin.

Cam = game.Workspace.CurrentCamera
Player = script.Parent.Parent.Parent
Count = 0

function onKeyDown(key) 
    Players = game.Players:getChildren()
    lkey = key:lower()

    if lkey == "e" then
        Count = Count+1
        if Count>#Players then
            Count = 1
        end
        if Players[Count]~=Player then
            Cam.CameraSubject = Players[Count].Character.Head
        else
            Count = Count+1
            if Count>#Players then
                Count = 1
            end
            Cam.CameraSubject = Players[Count].Character.Head
        end
    end
    if lkey == "q" then
        Count = Count-1
        if Count<1 then
            Count = #Players
        end
        if Players[Count]~=Player then
            Cam.CameraSubject = Players[Count].Character.Head
        else
            Count = Count-1
            if Count<1 then
                Count = #Players
            end
            Cam.CameraSubject = Players[Count].Character.Head
        end
    end
end
function UnEquipped()
    game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
    game.Workspace.CurrentCamera.CameraType = "Custom"
end
function onSelected(mouse) 
mouse.KeyDown:connect(onKeyDown) 
end 
script.Parent.Deselected:connect(UnEquipped)
script.Parent.Selected:connect(onSelected)

1 answer

Log in to vote
0
Answered by
RedCombee 585 Moderation Voter
10 years ago

You have to change the Camera's Coordinate Frame to anywhere near the spectated player's head so they are visible on the screen.

Ad

Answer this question