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

How do I attatch the camera to a part?

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?

2 comments

1

I made it look down sorry i'm a bit late.

0

Thanks!

1 answer

✓ Accepted answer

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 CFrame position 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)

 

1 comment

0

Is there a way to make it face the bottom instead of the side?

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