I want to achieve something where the camera always points in the direction of the head, but the player can still move it up and down and look around. Does anyone know how to do this?
Perhaps Camera | Documentation - Roblox Creator Hub could be of use to you. Or, you can set an offset for the camera to make the camera point in the direction of the player head, that also works
how do i program the camera to point to the head then?
Just change the camera type to attachment
can you script it for me? If i tried it would take a whole day
Some thing like this perhaps?
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local HEAD_OFFSET = Vector3.new(0, 0.5, 0) -- Offset to position camera slightly above head
local ROTATION_SPEED = 0.005 -- Adjust this value to change rotation sensitivity
local cameraAngleX = 0
local cameraAngleY = 0
local function updateCamera()
local head = Character:FindFirstChild("Head")
if not head then return end
-- Update camera position
local headCFrame = head.CFrame
local cameraPosition = headCFrame.Position + HEAD_OFFSET
-- Apply rotation
local cameraRotation = CFrame.fromEulerAnglesYXZ(cameraAngleY, cameraAngleX, 0)
local cameraCFrame = CFrame.new(cameraPosition) * cameraRotation
Camera.CFrame = cameraCFrame
end
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
cameraAngleX = cameraAngleX - input.Delta.X * ROTATION_SPEED
cameraAngleY = cameraAngleY - input.Delta.Y * ROTATION_SPEED
-- Clamp vertical rotation to prevent over-rotation
cameraAngleY = math.clamp(cameraAngleY, -math.pi/2, math.pi/2)
end
end)
RunService.RenderStepped:Connect(updateCamera)
-- Lock mouse to center of screen
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
The script does make me go in first person and able to see my body, however I can rotate my camera 360 degrees as well as see my accessories. I want to achieve the camera behaving like a headcam
You aren’t supposed to ask for full systems on the devforum.
If i understand correctly what you want is to set the camera type or whatever it was called to LockFirstPerson in StarterPlayer?
doesn’t lock first person make you not able to see your own body??
What do you want to happen? To see your own body but be in first person?
If so, then I think your best bet is to try to find where Roblox makes your body transparent when in first person and adjust it to only affect the head and maybe the torso
first person body transparency cannot be changed i think, what people normally do is to change the camera to scriptable and do something i cannot comprehend