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

Making a camera follow above the player?

Asked by 3 years ago
Edited 3 years ago

So I'm making a 2d game and i want the camera to follow above the player. My idea was to use the position property and make it follow the players head only using the two axis.

while true do
    script.Parent.Position.Z = game.Players.LocalPlayer.CharacterAdded:Wait("Head").Position.Z
    script.Parent.Position.X = game.Players.LocalPlayer.CharacterAdded:Wait("Head").Position.X
end

I'm a noob at scripting and much help would be appreciated

2 answers

Log in to vote
0
Answered by 3 years ago

Figured it out myself lol

while true do
    game.Workspace.Part.CFrame = game.Players.LocalPlayer.Character.Head.CFrame + Vector3.new(0,15,0)
    wait(1)
end
Ad
Log in to vote
0
Answered by 3 years ago

Here is the script

local Camera = workspace.CurrentCamera
Camera.CameraSubject = Enum.CameraType.Scriptable
local Character = game.Players.LocalPlayer.Character
local LockedOnTo Character:WaitForChild("Head") --This is what you want the camera to be locked on to
while wait() do
    Camera.CFrame = CFrame.new(LockedOnTo.Position.X
        ,LockedOnTo.Position.Y
        , 20) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)) --This is the degree you would like the camera on
end

Answer this question