Hello, I am trying to get > RenderStepped to work for a Camera CFrame, as the Camera is set to Scriptable, however, The camera does not want to Stay with the Camera Part, As its moves or Rotate when the tool is equipped

And sometimes the output puts a warning as,

ActivateCameraController did not select a module

Any help on world be greatful on How I can Achieve the Camera CFrame to change with the Renderstepped.

local plane = script.Parent.FindCamera.Value
local cameras = plane:GetChildren()
local numCameras=#cameras
local cam = workspace.CurrentCamera
local currentView=0
local player=game.Players.LocalPlayer

local GUI = script.Parent:WaitForChild("Information GUI")


local runService = game:GetService('RunService')
local Stepped

local MaxFov = 45

function nextCamera()
	if currentView < numCameras then--if viewing a camera
		cam.CameraType = Enum.CameraType.Scriptable
		cam.CameraSubject = cameras[currentView+1]
		--cam.CoordinateFrame = cameras[currentView+1].CFrame
		currentView = currentView+1
		player.CameraMaxZoomDistance = 1
		cam.FieldOfView = MaxFov
	elseif currentView == numCameras then
		cam.CameraType = Enum.CameraType.Custom
		cam.CameraSubject = player.Character
		player.CameraMaxZoomDistance = 230
		cam.FieldOfView = MaxFov
		currentView = 0
	end
end



function prevCamera()
	if currentView > 1 then--if not on player
		print(""..currentView.."")
		cam.CameraType = Enum.CameraType.Scriptable
		cam.CameraSubject = cameras[currentView-1]
		--cam.CoordinateFrame = cameras[currentView-1].CFrame
		currentView = currentView -1
		player.CameraMaxZoomDistance = 1
		cam.FieldOfView = MaxFov
	elseif currentView == 1 then
		print(""..currentView.."")
		currentView = 0
		cam.CameraType = Enum.CameraType.Custom
		cam.CameraSubject = player.Character
		player.CameraMaxZoomDistance = 230
		cam.FieldOfView = MaxFov
	elseif currentView == 0 then
		print(""..currentView.."")
		cam.CameraType = Enum.CameraType.Custom
		currentView = numCameras
		cam.CameraSubject = cameras[currentView]
		--cam.CoordinateFrame = cameras[currentView].CFrame
		player.CameraMaxZoomDistance = 1
		cam.FieldOfView = MaxFov
	end
end

local mouse5 = game.Players.LocalPlayer:GetMouse()
mouse5.KeyDown:connect(function(key)
	if key == "m" then
		nextCamera()
	end
end)
mouse5.KeyUp:connect(function(key)
	if key == "n" then
		prevCamera()
	end
end)


function UnEquipped()
	Stepped:Disconnect()
	currentView = 0
	cam.CameraType = Enum.CameraType.Custom
	cam.CameraSubject=player.Character
	player.CameraMaxZoomDistance = 230
	GUI.Parent = script.Parent
	cam.FieldOfView = 70
end


function Equipped()
	GUI.Parent = player.PlayerGui
	cam.FieldOfView = 35
end


script.Parent.Selected:Connect(Equipped)
script.Parent.Deselected:Connect(UnEquipped)


Stepped = runService.RenderStepped:Connect(function()
	if currentView > 0 or currentView < 0 then -- One onboard camera
		cam.CFrame = cameras[currentView].CFrame
	end
end)

2 comments

0

no reason why this shouldnt work... i am confused as to why id doesnt work...

0

Why are you using mouse.KeyDown? It's deprecated. Use UserInputService instead.