How i can make Camera(Schoulder Cam) to Normal Cam?

i want make something like the Mad City guns
with the Schoulder Cam when you not have your gun in hands schoulder cam stops.

This is what i tried:

function CamModule:Stop()
       local cam = game.Workspace.Camera

       cam.CameraType = "Fixed"
end

and here the Module Script:

local CamModule = {}

function CamModule:SchoulderCam() --StarterCharacterScripts
	local uis = game:GetService("UserInputService")


	local camera = workspace.CurrentCamera
	camera.CameraType = Enum.CameraType.Scriptable


	local char = script.Parent.Parent

	local humanoid = char:WaitForChild("Humanoid")
	humanoid.AutoRotate = false

	local hrp = char:WaitForChild("HumanoidRootPart")


	local x = 0
	local y = 0


	local offset = Vector3.new(3, 3, 10)


	uis.InputChanged:Connect(function(input, processed)

		if processed then return end

		if input.UserInputType == Enum.UserInputType.MouseMovement then

			x = x - input.Delta.X

			y = math.clamp(y - input.Delta.Y*0.4, -75, 75)


			hrp.CFrame = hrp.CFrame * CFrame.Angles(0, math.rad(-input.Delta.X), 0)
		end
	end)


	game:GetService("RunService").RenderStepped:Connect(function()

		uis.MouseBehavior = Enum.MouseBehavior.LockCenter


		local startCFrame = CFrame.new((hrp.CFrame.Position)) * CFrame.Angles(0, math.rad(x), 0) * CFrame.Angles(math.rad(y), 0, 0)
		local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, offset.Z))
		local cameraDirection = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, -10000))

		camera.CFrame = CFrame.new(cameraCFrame.Position, cameraDirection.Position)
	end)
end
--------------------------------
function CamModule:TopDownCam() --StarterCharacterScripts
	local cam = workspace.CurrentCamera

	local char = script.Parent.Parent
	local hrp = char:WaitForChild("HumanoidRootPart")


	cam.CameraType = Enum.CameraType.Scriptable


	local cameraPart = Instance.new("Part")
	cameraPart.Transparency = 1
	cameraPart.CanCollide = false
	cameraPart.Parent = workspace

	cameraPart.CFrame = CFrame.new(hrp.Position + Vector3.new(0, 20, 0), hrp.Position)


	local bp = Instance.new("BodyPosition")
	bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	bp.Parent = cameraPart


	game:GetService("RunService").RenderStepped:Connect(function()

		bp.Position = hrp.Position + Vector3.new(0, 20, 0)

		cam.CFrame = cameraPart.CFrame
	end)
end
--------------------------------
function CamModule:TwoDCam() --StarterGui
	local Camera = game.Workspace.CurrentCamera
	local Player = game.Players.LocalPlayer

	repeat
		wait()
	until Player.Character

	local Player = Player.Character
	local HumanoidRootPart = Player.HumanoidRootPart

	local Positioner = Instance.new("BodyPosition", HumanoidRootPart)
	Positioner.MaxForce = Vector3.new(0, 0, math.huge)
	Positioner.Position = Vector3.new(0, 0,HumanoidRootPart.Position.Z)

	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CameraSubject = Player.HumanoidRootPart

	game:GetService("RunService").RenderStepped:connect(function()
		Camera.CFrame = CFrame.new(HumanoidRootPart.CFrame.X, HumanoidRootPart.CFrame.Y, HumanoidRootPart.CFrame.Z + 30)
		Camera.FieldOfView = 50
	end)
end
--------------------------------
function CamModule:Stop()
	local cam = game.Workspace.Camera

       cam.CameraType = "Fixed"
end
return CamModule

not work… hmm

1 Like

CameraType has a value of Enum.CameraType. You are setting it to a string. Also, you should try and set it back to Custom when done.

function CamModule:Stop()
       local cam = game.Workspace.Camera
       cam.CameraType = Enum.CameraType.Custom
end
1 Like

i will test it out
Thanks for Helping!

ok im sorry… not work… ):

1 Like

Is there any errors in the console?

no errors in the console but the function is startet…

I think this should be CurrentCamera.

function CamModule:Stop()
       local cam = game.Workspace.CurrentCamera
       cam.CameraType = Enum.CameraType.Custom
end

still not working.

Where is the function being called from? Also, check in workspace to see if it is actually setting your CameraType.

from a local script:

local CamModule = require(script:WaitForChild("CamModule"))

CamModule:SchoulderCam()
wait(20)
print("STOP")
CamModule:Stop()

Ohh i found the x,y,z from the camera. ok i found not the x,y,z from the camera