local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera
RunService:BindToRenderStep("UpdateLoop", Enum.RenderPriority.Camera.Value, function()
local rX, rY, rZ = camera.CFrame:ToOrientation()
local limX = math.clamp(math.deg(rX), -80, 35)
camera.CFrame = CFrame.new(camera.CFrame.p) * CFrame.fromOrientation(math.rad(limX), rY, rZ)
end)
Currently I have this script inside of StarterPlayerScripts, but it shakes the camera uncontrollably when you try to look all the way up. How can I fix this and make it as smooth as it should be?
I like it, but it just moves the camera back to the specified angle if you move it to far, it doesn’t simply limit the camera’s Y axis movement? It’s great, but not really what I wanted, sorry…
(Your script is amazing but for another purpose)
This is just a side effect of not being at the barebones code and trying to modify something after it already occurred. I copied the barebones camera script, pressed stop, and pasted it into StarterPlayerScripts. In that script, there are variables named MAX_Y and MIN_Y. Change these to your liking. I changed the MIN_Y = -80; MAX_Y = 35; as that is what I saw you attempt to do with your code.
Keep in mind I forked the PlayerModule script. If Roblox applies a new update upon these scripts and you want them, it won’t be that much work, as this changed one variable. You can delete the script in StarterPlayerScripts, playtest the game, find it while playtesting in StarterPlayerScripts, copy it, stop playtesting, paste the new version into StarterPlayerScripts out of playtest mode, and make the small changes to the MIN_Y and MAX_Y variables.
I hope this solved your issue! No cool lerping or camera glitchiness here! If this helped, please mark me as solution.