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

How can I get the Camera focused on humanoid?

Asked by 10 years ago
local target = workspace.Grass
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
local angle = 100
local i = 0
 --------------------------------------- Stuff inbetween these green lines is just a starting thing.
while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position)
                            * CFrame.Angles(0, angle, 0)
                            * CFrame.new(0, 100, 200)
    angle = angle + math.rad(1)
end
-------------------------------------- I want the below to stop the above and change camera to the humanoid
function onClick()
    game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end

script.Parent.StartGui.ClassFrame.Buttons.PlayKnightButton.MouseButton1Click:connect(onClick)

Why dosent this work? I have it in a LocalScript, and I want it to check if the script.Parent.StartGui.ClassFrame.Buttons.PlayKnightButton is clicked and then change the cameras subject to humanoid. Any ideas?

Answer this question