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)
