Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making a camera follow above the player?

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.