The problem is it glitches when I look up and down (or above rotation degrees as 81) I don’t want that to happen. I also want it without making camera as scriptable, (For first person and third person, Mainly for first person). Apparently I tried adding the camera subject to the humanoid but it does nothing, I tried looking or searching up similar posts but I can’t find them too, well I found a few but it’s not what I wanted.
local uis = game:GetService("UserInputService")
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character
uis.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
local delta = uis:GetMouseDelta()
print(delta)
local X = delta.X
local Y = delta.Y
cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(-Y),math.rad(-X),math.rad(0))
end
end)
I believe this post is what you are looking for and unfortunately yeah.
the camera will have to be scriptable or else the glitch will happen as the default camera script prevents the camera from going over the 81 degree zone.
When I set it to scriptable, It breaks the script (No errors though, maybe it overrides the script, I can’t move my camera and it’s not focusing the character.) https://gyazo.com/fda3766b27df54bb745f8e4bbdb2019c
Making the camera type scriptable doesn’t break your script, it just disables most of the default camera behavior allowing you to script your own. I’m not experienced with camera manipulation but the link @CRAFTRONIX_457 sent should help you.
I did what u said, It works when I rotate. But not when I move my character. I cannot do this but what I can think of is I want to get its lookvector for head (in line 7), but if I added code at line 7 to renderstep, it will just override, glitches and cannot rotate. How can I do that?
wait(1)
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = plr.Character.Head.CFrame -- how do i get its lookvector? (Also for first person) and i didnt add it in renderstep because it will override the rotation
rs.RenderStepped:Connect(function(step)
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
local delta = uis:GetMouseDelta()
--print(delta)
local x = delta.X
local y = delta.Y
cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(-y),math.rad(-x),math.rad(0))
end)```