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

Camera help please?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

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

Log in to vote
1
Answered by 8 years ago

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!

Ad

Answer this question