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

Camera help please?

This script makesthe camera still pointing at baseplate. I want to get the players and when a player joins, the camera is focussed on their own head. I have tried, I can't seem to do it.

local target = workspace.Baseplate
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
local angle = 0
local i = 0
 
while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position) 
							* CFrame.new(0, 10, 10) 
    angle = angle + math.rad(1)
 
	i = i + 1
	if i > 1000 then break end
end

1 answer

✓ Accepted answer

As we discussed in chat, if your script is in the starter gui, here is the code you need:

local target = game.Players.LocalPlayer.Character.Head --the simplest way to access the Players character
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
local angle = 0
local i = 0

while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position) 
                            * CFrame.new(0, 10, 10) 
    angle = angle + math.rad(1)

    i = i + 1
    if i > 1000 then break end
end

And that's it!

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