I have this simple script that sets the camera to the player’s head. I’m using it because I am trying to have the camera follow my animations in game. However, using this script, I am unable to rotate the camera using the mouse. I am not very experienced in camera manipulation. How can I fix this?
Script:
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() -- if character does not exist we will wait for it to exist.
Head = Character:WaitForChild("Head") -- Get's the Player head in Workspace
local RunService = game:GetService("RunService") -- Defines RunService
workspace.CurrentCamera.CameraSubject = Character.Head
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
RunService.RenderStepped:Connect(function()
workspace.CurrentCamera.CFrame = Head.CFrame -- Should set the Camera CFrame to the head, but that is not happening
end)
Maybe turn the CameraType to Enum.CameraType.Custom after you are done setting the Camera’s CFrame to the player’s head’s CFrame. I’m not 100% sure if that will work though.
The rest of the code works to set the camera’s position to the head, but we just want the camera to follow the head. This will allow you to move the camera freely.
Setting the CameraType to custom or scriptable will break this method.
This worked perfectly for allowing the player to freely move the camera, but now the player is unable to rotate the player using the mouse. Please note that my game is in first person lock.
This didn’t work either, and @Xitral already mentioned that setting the CameraType to Custom or Scriptable would break it. Thanks for the suggestion, though!