My Script:
local gui = script.Parent
local player = game.Players.LocalPlayer
local cam = game.Workspace.Camera
local distance = 10
local p = game.Workspace:FindFirstChild(player.Name)
local UIS = game:GetService("UserInputService")
local check = false
script.Parent.Menu2.Training.MouseButton1Click:Connect(function()
p.LowerTorso.CFrame = CFrame.new(0, 1066.35+5, 31.286)
p.LowerTorso.Anchored = false
focushere = game.Workspace:FindFirstChild(player.Name).focus
cam.CameraSubject = focushere
p.Humanoid.Jump = true
p.LeftFoot.Touched:Connect(function()
if check == false then
cam.CameraType = "Fixed"
script.parent.Menu2.Visible = false
script.parent.Background.Visible = false
game.Players.LocalPlayer.CameraMaxZoomDistance = distance
game.Players.LocalPlayer.CameraMinZoomDistance = distance
cam.CFrame = CFrame.new(9.9973382949829,focushere.CFrame.Y,focushere.CFrame.Z) -- z = 27.442066192627 y =
--cam.CoordinateFrame = focushere.CFrame * CFrame.new(8,0,0) --* CFrame.Angles(0,0,math.rad(2))
check = true
p.Check.Value = true
else
return
end
end)
end)
repeat
wait()
until gui.Startgame.Visible == false and gui.Menu.Visible == false and gui.Menu2.Visible == false
function rotate()
local root_part_one = game.Workspace:FindFirstChild(player.Name).HumanoidRootPart
local root_part_two = game.Workspace.StarterCharacter.HumanoidRootPart
-- Face player 1 towards player 2
root_part_one.CFrame = CFrame.new(root_part_one.Position, root_part_two.Position)
-- Face player 2 towards player 1
root_part_two.CFrame = CFrame.new(root_part_two.Position, root_part_one.Position)
end
function follow()
--cam.CoordinateFrame = cam.CoordinateFrame * CFrame.new(1,0,0)-- * CFrame.Angles(0,0,math.rad(2))
cam.CFrame = CFrame.new(9.9973382949829,focushere.CFrame.Y,focushere.CFrame.Z)
end
check3 = true
game:GetService("RunService").RenderStepped:Connect(function()
p.Humanoid.Jumping:Connect(function()
check3 = false
end)
if(check3 == true) then
if(p.Humanoid.Health > 0) then
--rotate();
follow()
end
else
check3 = true
end
end)
Problem: Why is it that when I try setting Y and Z values of the Camera's CFrame to the Y and Z values of focus, the camera just faces forward? What I hope to happen is for the camera to face the right side of my player similar to that of a 2D game. Anyone have any clue what I did wrong or have a better solution to this? If so please help!
Clarification: focus and focushere is the same thing, Its just a part I place in front of my player's head to be the Camera's focus.

1 comment
You can get position from CFrame using CFrame.p which returns the position in Vector3, then CFrame.p.x for example