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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
I get "Attempt to index nil with 'x'" YelloMynamesZak 85 — 4y
0
idk the structure of ur script, access the player's camera and character in the context of ur script. this is an example... User#23252 26 — 4y
Ad

Answer this question