When someone joins the game, I want their camera to lock onto an object (can not move it) so I can create a menu there. Like it will lock onto looking somewhere and they can select start game and stuff.
Example: On an adventure game it shows an overview of the map
you can use the CurrentCamera
s CFrame
of workspace by changing the CameraType
to Scriptable like this:
1 | local camera = workspace.CurrentCamera |
2 | local player = game.Players.LocalPlayer |
3 | local char = player.Character |
4 |
5 | wait( 0.1 ) |
6 | camera.CameraType = Enum.CameraType.Scriptable -- changes so we can script it |
7 | camera.CFrame = workspace.Block.CFrame -- define what Part you want to lock the camera on |
also make sure its a local script and your Part is facing your target or whatever. if you want to make the camera go to normal you can just set the CameraType
to Custom, such as this:
1 | local camera = workspace.CurrentCamera |
2 | local player = game.Players.LocalPlayer |
3 | local char = player.Character |
4 |
5 | camera.CameraType = 'Custom' -- changes it to the default camera |