Need help making camera script

I’m making a new 2D platformer game, and I need help making a script
What I want is for the camera to always be facing the same direction, but I still want it to move with the player.


(this shows the direction I need the camera to face)

However, I’m pretty new to roblox studio and I don’t even know where to start with something like this!
Any help is appreciated, thanks : )

i search up what you want and this was the first result

Made this simple script for you:

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local character = player.Character or player.CharacterAdded:Wait()

-- Set the initial camera position and orientation
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(character:WaitForChild("Head").Position + Vector3.new(30, 10, 0), character.Head.Position)

-- Update camera position to follow the player
game:GetService("RunService").RenderStepped:Connect(function()
	if character and character:FindFirstChild("Head") then
		-- Adjust the camera's position based on the player's position
		local targetPosition = character.Head.Position + Vector3.new(30, 10, 0) -- Adjust the offset values as needed
		camera.CFrame = CFrame.new(targetPosition, character.Head.Position)
	end
end)

As you can see:

Place script as a local script inside PlayerStarterScripts or you can adjust it as a CharacterStarterScript

1 Like

The script works great but camera breaks when the player respawns, any ideas on how to fix this?

Make it a StarterCharacterScript or do a CharacterAdded function