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

Why does this not face the part?


local target = workspace.THEPARTINEED
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position)  --Start at the position of the part
                          
end

The camera is still but is not looking at the part?

Any ideas?

1 answer

Scriptable camera will ignore both CameraSubject and Focus. It's whole purpose is to be fully controlled by your own code. This should work:

local target = workspace.THEPARTINEED
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position, target.Position + target.CFrame.lookVector) 
end

Right now it will face same direction the part is oriented at, since I wasn't sure where exactly the camera should be located and where it should look.

Also consider using RenderStepped, since wait() is only 1/24 of a second, while roblox renders more often than that. Check these out:

http://wiki.roblox.com/index.php?title=API:Class/RunService/RenderStepped http://wiki.roblox.com/index.php?title=API:Class/RunService/BindToRenderStep

I'd personally use runService:BindToRenderStep(), otherwise do runService.RenderStepped:wait().

3 comments

0

Thank you very much but it doesn't work :/ It just locks the camera on the player.

0

Hm, I guess you set the target to player's head? Well, that is what it should do, look at the part. At least that's what I understood from your post.

0

Yeah, although I copied it exactly and it locked it to the players head and not the part :/ I will carry on trying to figure it out..

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