How to rotate the camera by specific angles when pressing < > / ,

Hello, as of again, i want to know how to do this effect:

Ok, i will have to explain, the video quality is for some reason, just no.

What i want to achieve is this: In some games, you can actually press the < > / , . keys to rotate your character, this is something useful for obbies that contains “Wall Hop”.

Whenever you press those keys, your camera will rotate 45 degrees/radians, and not even that, it will actually “center” you, here is what i mean:

Comma pressed:

PhoenixRessusection’s character/HRP is rotated 1 degrees: Rotate him to 0 degrees then.

PhoenixRessusection’s character/HRP is rotated -1 degrees: Rotate him to 45 degrees then.

Period pressed

PhoenixRessusection’s character/HRP is rotated 1 degrees: Rotate him to 0 degrees then.

PhoenixRessusection’s character/HRP is rotated -1 degrees: Rotate him to -45 degrees then.

I heard that this was an roblox’s camera module, but even if it were, i have no idea on how to actually find it.

Here is my current code:

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera

local LeftRotation = CFrame.Angles(0,math.rad(45),0)
local RightRotation = CFrame.Angles(0,math.rad(-45),0)
-- Sorry if those are reversed XD...

UIS.InputBegan:Connect(function(Input)
	local char = plr.Character or plr.CharacterAdded:Wait()
	
	if Input.KeyCode == Enum.KeyCode.Comma then
		local OldYCFrame = Camera.CFrame.Y
		
		
		print("Pressed Comma( , )")
		Camera.CFrame = Camera.CFrame * LeftRotation 
		
	elseif Input.KeyCode == Enum.KeyCode.Period then
		local OldYCFrame = Camera.CFrame.Y
		
		
		print("Pressed Period( . )")
		Camera.CFrame = Camera.CFrame * RightRotation 
		
	end
end)

This works just fine(Except without the thing that has knowledge on the player’s rotation and the next one), except that i have noticed an weird like issue, whenever press the keys, my camera also goes down! I tried to do something like this:

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera

local LeftRotation = CFrame.Angles(0,math.rad(45),0)
local RightRotation = CFrame.Angles(0,math.rad(-45),0)

UIS.InputBegan:Connect(function(Input)
	local char = plr.Character or plr.CharacterAdded:Wait()
	
	if Input.KeyCode == Enum.KeyCode.Comma then
		local OldYCFrame = Camera.CFrame.Y
		
		
		print("Pressed Comma( , )")
		Camera.CFrame = Camera.CFrame * LeftRotation
		Camera.CFrame = Camera.CFrame + Vector3.new(0,OldYCFrame,0)
		
	elseif Input.KeyCode == Enum.KeyCode.Period then
		local OldYCFrame = Camera.CFrame.Y
		
		
		print("Pressed Period( . )")
		Camera.CFrame = Camera.CFrame * RightRotation
		Camera.CFrame = Camera.CFrame + Vector3.new(0,OldYCFrame,0)
		
	end
end)

But no success, alright, can anyone help me with this / show the camera module of this?(If it exists.)

That is a built-in part of the old camera system. You should be able to find the version they used somewhere on the Roblox Github page for the CameraScript.

3 Likes

You may find this useful, this is from an obby community where we do require these scripts. This is a modified version of the defual camera scripts.
https://www.roblox.com/library/4155652605/Fix

Fair warning, this will not get updated with camera patches and fixes.

4 Likes

Thank you! I will definitely use this in the future, and recommend to other people if possible.

Just cause i’am someone who likes to make plugins of whatever you could think of, i made an <> Fix Inserter. :man_shrugging: