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

How do I make the camera always face the back of the player?

So I am making a racing game, and the make it more advanced, I want to make it so the camera always faces the back of the player, and the player can't zoom in or out. How do I achieve this?

1 answer

The methods of CFrames sound pretty handy in this case..

assuming you have access to the player's character, here's a method that might hopefully work

local RunService = game:GetService("RunService");

local camera  = x.y.Camera--the camera object
local character = x.y.Character --the player's character

RunService.Stepped:Connect(function()
	camera.CameraType = Enum.CameraType.Scriptable
	local head = character.Head;
	
	local behind = head.CFrame:ToWorldSpace(CFrame.new(0, 0, 10));
	camera.CFrame = CFrame.new(head.Position, behind.Position)
end)

2 comments

0

I get "Attempt to index nil with 'x'"

0

idk the structure of ur script, access the player's camera and character in the context of ur script. this is an example...

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