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

How do I attatch the camera to a part?

Asked by
ExcelUp 24
9 years ago

I named a part 'cameraPart'.

I put a LocalScript in the StarterGUI, to make the script appear in the player when they spawn, which it did.

The line of code I entered was:

game.Workspace.CurrentCamera.CameraSubject = game.Workspace.cameraPart

All it does is put the camera where the camera was left off in ROBLOX Studio, instead of attatching the camera to the part.

Can someone help me please?

1
I made it look down sorry i'm a bit late. Thetacah 712 — 9y
0
Thanks! ExcelUp 24 — 9y

1 answer

Log in to vote
3
Answered by
Thetacah 712 Moderation Voter
9 years ago

I looked around in the wiki and put this together to work.

I changed the Camera's CameraType to Scriptable(so the script has complete control over the camera), then I changed the Camera's CoordinateFrame property(Which is the CFrameposition of the camera) to target.position, then moved it back by 5 units so you can see the part

I used CFrame.Angles() to change the angle of where it's looking at.(down)

Sorry for the poor explaining here, I don't have much experience with cameras. Read more on cameras here.

The end code should look like this.


local target = workspace.cameraPart local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target camera.CoordinateFrame = CFrame.new(target.Position)* CFrame.Angles(-180, 0, 0)*CFrame.new(0,0,5)
0
Is there a way to make it face the bottom instead of the side? ExcelUp 24 — 9y
Ad

Answer this question