PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetRoll

This function returns, in radians, the current roll applied to the Camera using Camera/SetRoll. Roll is defined as rotation around the Camera|Camera’s Z-axis.

This function only returns roll applied using the Camera/SetRoll function. Roll manually applied to the Camera|Camera’s Camera/CFrame is not accounted for. To obtain the actual roll of the Camera, including roll manually applied, you can use the following snippet:

local function getActualRoll()
	local camera = workspace.CurrentCamera

	local trueUp = Vector3.new(0, 1, 0)
	local cameraUp = camera:GetRenderCFrame().upVector

	return math.acos(trueUp:Dot(cameraUp))
end

Returns

Return Type Summary

The current roll applied by Camera/SetRoll, in radians


Code Samples


Camera:GetRoll

This example, when used in a /LocalScript, will retrieve the current roll of the camera in degrees. Then, if the camera roll angle is not 20 degrees, the camera roll angle is set to 20 degrees.

local currentRoll = math.deg(game.Workspace.CurrentCamera:GetRoll()) -- Gets the current roll of the camera in degrees.

if currentRoll ~= 20 then
	game.Workspace.CurrentCamera:SetRoll(math.rad(20)) -- If the camera isn't at 20 degrees roll, the roll is set to 20 degrees.
end