Using Roblox Poppercam with custom camera

You can write your topic however you want, but you need to answer these questions:
I am trying to use the roblox Poppercam module found in in PlayerModule.CameraModule to give this custom camera script a decent poppercam. I apologize for the mess but I have been trying to throw in other 3rd person camera’s to see if it is the scripts problem or not, and have been met with the same error.
The problem:

Not trying to use the poppercam:
https://gyazo.com/b709793c8ea988a91a52ab69de177a43
Using the poppercam:
https://gyazo.com/e80b8285c674aae1ed752d2d35b3a676

I have found only one post about using the poppercam with a custom camera which hasn’t given me any results.

Any help is appreciated.

Camera Code
(I Am using AeroFramework btw):

local CameraController = {}

--//Camera Script//--
--Services
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local TweenS = game:GetService("TweenService")

--Player
local Player = game.Players.LocalPlayer
repeat
	wait()
until Player.Character
repeat
	wait()
until Player.Character.Humanoid
repeat
	wait()
until Player.Character.HumanoidRootPart
local Character = Player.Character

local context = game:GetService("ContextActionService")

local HumanoidRootPart = Character.HumanoidRootPart
local Humanoid = Character.Humanoid
--local CamScript = Player.PlayerScripts.CameraScript
--CamScript.Disabled = true
--Humanoid.AutoRotate = false
local PopperC = require(Player.PlayerScripts.PlayerModule.CameraModule.Poppercam)
--Mouse
local Mouse = Player:GetMouse()
local xAngle = 0
local yAngle = 0
local cameraPos = Vector3.new(2, 0, 8.5)
--Variables
context:BindAction("CameraMovement", function(_, _, input)
	xAngle = xAngle - input.Delta.x * 0.4
	yAngle = math.clamp(yAngle - input.Delta.y * 0.4, -80, 80)
end, false, Enum.UserInputType.MouseMovement)

local Popper = false --	Sets whether Popper Cam behaviour is enabled
local DeltaX = 0
local DeltaY = 0
local AngleH = 0
local AngleV = 0
local SensitivityY = 120 --	Determines how large a change in vertical angle is through a mouse rotation
local SensitivityX = 120 --	Determines how large a change in the horizontal angle is through a mouse rotation
local W = false
local A = false
local S = false
local D = false
local Offset = Instance.new("CFrameValue")
Offset.Value = CFrame.new(3, 2, 5) --	Determines the CFrame by which the camera is pushed from the CFrame of the HumanoidRootPart
local MaxY = 5 * math.pi / 12 --	Determines maximum vertical angle
local MinY = -5 * math.pi / 12 --	Determines minimum vertical angle
local Combinations = {
	{ true, false, false, false, 0, 0 },
	{ true, true, false, false, math.pi / 4 },
	{ false, true, false, false, math.pi / 2 },
	{ false, true, true, false, 3 * math.pi / 4 },
	{ false, false, true, false, math.pi },
	{ false, false, true, true, 5 * math.pi / 4 },
	{ false, false, false, true, 3 * math.pi / 2 },
	{ true, false, false, true, 7 * math.pi / 4 },
}

local cameraPosition = Vector3.new(2, 1, 4)
--Camera
local Cam = game.Workspace.CurrentCamera
Cam.CameraType = Enum.CameraType.Scriptable
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
local pop = PopperC.new()
pop:Enable()
--Functions
UIS.InputBegan:Connect(function(Input, gamec)
	if gamec then
		return
	end
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then
		if Player.Character.CamControl.ArtilleryView.Value == false then
			Cam.CameraType = Enum.CameraType.Scriptable
			Player.Character.CamControl.Aiming.Value = true
		end
	end
end)
UIS.InputEnded:Connect(function(Input, gamec)
	if gamec then
		return
	end
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then
		Player.Character.CamControl.Aiming.Value = false
		--	Cam.CameraType = Enum.CameraType.Custom
	end
end)

UIS.InputBegan:Connect(function(input, a)
	if a then
		return
	end
	-- Shoulderswap
	if input.KeyCode == Enum.KeyCode.Q then
		if
			Player.Character.CamControl.Shoulder.Value == "Right"
			and Player.Character.CamControl.ArtilleryView.Value == false
		then
			local tween = TweenS:Create(Offset, TweenInfo.new(0.5), { Value = CFrame.new(-3, 2, 5) })

			tween:Play()
			Player.Character.CamControl.Shoulder.Value = "Left"
		elseif
			Player.Character.CamControl.Shoulder.Value == "Left"
			and Player.Character.CamControl.ArtilleryView.Value == false
		then
			local tween = TweenS:Create(Offset, TweenInfo.new(0.5), { Value = CFrame.new(3, 2, 5) })

			tween:Play()
			Player.Character.CamControl.Shoulder.Value = "Right"
		end
	end
end)

function CameraController:ArtilleryCamera(Setup)
	if Player.Character.CamControl.ArtilleryView.Value == true and Setup == "Down" then
		if Player.Character.CamControl.Shoulder.Value == "Left" then
			local tween = TweenS:Create(Offset, TweenInfo.new(0.5), { Value = CFrame.new(-3, 2, 5) })

			tween:Play()
		else
			local tween = TweenS:Create(Offset, TweenInfo.new(0.5), { Value = CFrame.new(3, 2, 5) })

			tween:Play()
		end
		local tween = TweenS:Create(Offset, TweenInfo.new(0.5), { Value = CFrame.new(3, 2, 5) })

		tween:Play()
		Player.Character.CamControl.ArtilleryView.Value = false
	elseif
		Player.Character.CamControl.ArtilleryView.Value == false
		and Player.Character.CamControl.Aiming.Value == false
		and Setup == "Up"
	then
		local tween = TweenS:Create(Offset, TweenInfo.new(0.5), { Value = CFrame.new(0, 15, 1) })

		tween:Play()
		Player.Character.CamControl.ArtilleryView.Value = true
	end
end
Player.CharacterAdded:Connect(function(Char)
	print("Loaded Char")
	Character = Char
	HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
end)

local function camUpdate(dt, CamCFrame,CamFocus)
	if Character and HumanoidRootPart then
		local newCamCFrame, newCamFocus = pop:Update(dt, CamCFrame, CamFocus)

		game.Workspace.CurrentCamera.CFrame = newCamCFrame
		game.Workspace.CurrentCamera.Focus = newCamFocus
	end
end

RunService.RenderStepped:Connect(function(step)
	if Character.CamControl.RocketArm.Value == true then
	end

	--camUpdate(step,FinalCFrame)

	if Player.Character.CamControl.Aiming.Value == true and Cam.CameraType == Enum.CameraType.Scriptable then
		HumanoidRootPart.CFrame = CFrame.new(
			HumanoidRootPart.CFrame.Position,
			Vector3.new(Mouse.Hit.p.X, HumanoidRootPart.CFrame.Position.Y, Mouse.Hit.p.Z)
		)
	end

	AngleH = AngleH - DeltaX / SensitivityX
	DeltaX = 0
	AngleV = math.clamp(AngleV - DeltaY / SensitivityY, MinY, MaxY)
	DeltaY = 0
	--   local FinalCFrame
	--local FinalCFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0, AngleH, 0) * CFrame.Angles(AngleV, 0, 0) * Offset.Value
	--local startCFrame = CFrame.new((HumanoidRootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, AngleH, 0)*CFrame.Angles(AngleV, 0, 0)
	-- local cameraCFrame = startCFrame + startCFrame:VectorToWorldSpace(Vector3.new(3,1,2))
	--local cameraFocus = startCFrame + startCFrame:VectorToWorldSpace(Vector3.new(3,0,-5000000))

	--	game.Workspace.CurrentCamera.CFrame= cameraCFrame
	--	game.Workspace.CurrentCamera.Focus = cameraFocus
	if Character and HumanoidRootPart then                   -- ### Here is where the main camera movement code is, 
		local startCFrame = CFrame.new((HumanoidRootPart.CFrame.p + Vector3.new(0, 2, 0)))
			* CFrame.Angles(0, math.rad(xAngle), 0)
			* CFrame.Angles(math.rad(yAngle), 0, 0)

		local cameraCFrame = startCFrame + startCFrame:VectorToWorldSpace(Vector3.new(cameraPos.X, cameraPos.Y, cameraPos.Z))
		local cameraFocus = startCFrame + startCFrame:VectorToWorldSpace(Vector3.new(cameraPos.X, cameraPos.Y, -50000))
		Cam.CFrame = CFrame.new(cameraCFrame.p,cameraFocus.p)
		camUpdate(step, Cam.CFrame, Cam.Focus) 
		--Ca.CFrame = CFrame.new(cameraCFrame.p,cameraFocus.p)
	end

	
	--game.Workspace.CurrentCamera.CFrame = FinalCFrame
--[[
	if Popper == true then
		local Direction = (FinalCFrame.p - Character.Head.Position).Unit * (Offset.Value.p).Magnitude

		local CheckRay = Ray.new(Character.Head.Position, Direction)
		local Part, Position = game.Workspace:FindPartOnRay(CheckRay, Character, false, true)
		if Part then
			local Distance = Cam:GetLargestCutoffDistance({ Character })
			Cam.CoordinateFrame = Cam.CoordinateFrame * CFrame.new(0, 0, -Distance)
		end
	end
	if (W == true) or (A == true) or (S == true) or (D == true) then
		for Num, Val in pairs(Combinations) do
			if (Val[1] == W) and (Val[2] == A) and (Val[3] == S) and (Val[4] == D) then
				local DirectionVector = Cam.CoordinateFrame.lookVector
				local Position = HumanoidRootPart.Position
				local TargetCFrame = CFrame.new(
					HumanoidRootPart.Position,
					HumanoidRootPart.Position + Vector3.new(DirectionVector.X, 0, DirectionVector.Z)
				)
				if CameraController.Controllers.CoverController:IsInCover() == false then
					HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:lerp(
						TargetCFrame * CFrame.Angles(0, Val[5], 0),
						0.25
					)
				end
			end
		end
	end]]
end)

UIS.InputChanged:Connect(function(Input, Bool)
	if Bool == false then
		if Input.UserInputType == Enum.UserInputType.MouseMovement then
			if 1 == 1 then
				if DeltaX ~= Input.Delta.X then
					DeltaX = Input.Delta.X
				end
				if DeltaY ~= Input.Delta.Y then
					DeltaY = Input.Delta.Y
				end
				-- UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
			else
				if DeltaY ~= Input.Delta.Y then
					DeltaY = Input.Delta.Y
				end
			end
		end
	end
end)
--[[
UIS.InputBegan:Connect(function(Input, Bool)
	if(Bool == false) then
		if(Input.KeyCode == Enum.KeyCode.W) then
			W = true
		elseif(Input.KeyCode == Enum.KeyCode.A) then
			A = true
		elseif(Input.KeyCode == Enum.KeyCode.S) then
			S = true
		elseif(Input.KeyCode == Enum.KeyCode.D) then
			D = true
		end
	end
end)

UIS.InputEnded:Connect(function(Input, Bool)
	if(Bool == false) then
		if(Input.KeyCode == Enum.KeyCode.W) then
			W = false
		elseif(Input.KeyCode == Enum.KeyCode.A) then
			A = false
		elseif(Input.KeyCode == Enum.KeyCode.S) then
			S = false
		elseif(Input.KeyCode == Enum.KeyCode.D) then
			D = false
		end
	end
end)]]

function CameraController:Start() end

function CameraController:Init() end

return CameraController

1 Like