Got a wallrun script, Help with tilting the camera?

So Lets say you are wallrunning to the right. Now in theory, It would only makes sense to tilt the camera to the left right? However, I wrote this code and it seems to print no errors however it seems like it’s not working. Here’s the code:

local camera = workspace.Camera
--wallrunning stuff
camera.CFrame = camera.CFrame * CFrame.Angles(0, 0, math.rad(45))

What am I doing wrong, and how can I fix it?

1 Like

As long as you’re not changing the CameraType of the camera then the rotation and position will either mess up or not even get changed. You could change the CameraType to “Custom” and then make some code so the camera will still follow the player. (Or you could just modify the default camera script) Because the current default camera script is still overwriting the cframe of the camera and the CameraType has not been changed, it does this.

Enum.CameraType.Custom is default, according to the Docs.

You could use CameraType scriptable and then use a combination of upvector and -lookvector to offset the camera while keeping the same rotation as the character, which might look something like this

cam.CameraType = Enum.CameraType.Scriptable

local function lock_camera()
    local hrp_cframe = hrp.CFrame
    local new_cframe = + hrp_cframe.upVector * offset_up + -hrp_cframe.lookVector * offset_back) * hrp_cframe.Rotation
    hrp.CFrame = new_cframe

I’m assuming your character is rotated when it wallruns.

I meant “Scriptable” :joy:. I was kinda tired so I didn’t really double check my message.

No, It actually isn’t, however I did manage to get it down by looking it up a little bit on Devforum.

				camera.CFrame = CFrame.lookAt(camera.CFrame.Position, camera.CFrame.Position + camera.CFrame.LookVector) * CFrame.Angles(0, 0, math.rad(angle))

			if (status == 0) then
				status = 2
				while (angle < 20) do
					local t = game:GetService("RunService").RenderStepped:Wait()
					angle = angle + rate * t
				angle = 20
				status = 1

Now how do I set the camera back to normal when the wallrun is done?

I’m pretty sure setting CameraType back to Custom does it

Wouldn’t work, because the camera never got unset from custom.

If your renderstepped is just locking the camera, disconnect it when the player stops wallrunning and it should go back to normal.

How can I do that? never heard of disconnecting tbh.

local connection
connection = RunService.RenderStepped:Connect(function() end)

You can also disconnect from inside of the connection.


while i was writing the script, it threw a warning, Unknown global ‘tiltLeft’ (that’s what I named it), does it have anything to do with being an if/else statement?

You have to first define the connection variable and then the line under it actually set it to the connection else the disconnect line will still not have access to the connection variable.

1 Like

yeah just realized i did that lol

1 Like

Hey, after a bit of tweaking, the camera effect should be fixed. Thank you.