✓ Accepted answer
How can I prevent the player from rotating their camera?
Considering the fact that you are creating a lobby camera, I will show you my preferred way of doing the following.
- 1) Create a
folder inside of Workspace. Name the folder CameraParts. Now, insert a part into the workspace and position it to your desire. Then, place the brick in the folder once you are done. Now we move on to scripting
Warning, this is a client-sided script only. Place it in StarterGui, StarterCharacterScript, StarterPlayerScipt
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local CameraFolder = Workspace:WaitForChild("CameraParts")
local CameraPart = CameraFolder:FindFirstChild("LobbyCamera1")
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = CameraPart.CFrame
Explanation
CurrentCamera is a property of Camera which defines the Camera Object of the Local Player. Basically we are telling the server that change the CurrentCamera to CameraPart
How can get the direction of which they spawn?
This really depends on two actions. Whether you are using Roblox Spawn or Manual Spawn
If you are using the Default Roblox Spawn, then just rotating it to the desired location will get you to your goal.
However, if you are using like your own spawn script, then we would have to force the player to face the particular way.
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local CameraFolder = Workspace:WaitForChild("CameraParts")
local CameraPart = CameraFolder:FindFirstChild("LobbyCamera1")
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = CameraPart.CFrame
HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position, CameraPart.Position)
Explanation
HumanoidRootPart is a property of Character and a reference to point to the Humanoid's root driving part. What we are doing here is the we are updating the default humanoid position to face the camera. No matter what position the player is in, they will always face the camera.
Hope you learned something. If error still persists, fell free to comment below.
#####Have a lovely day of coding.