ActivateCameraController did not select a module

My debounce is not working for some reason, It’s just stuck on the camera part.
If I provided little details, please tell me.
Here’s the actual script.

local UIS = game:GetService("UserInputService")
local inuse = false
local debounce = true

local function on()
	inuse = true
	while inuse == true do
		workspace.CurrentCamera.CameraType = "Scriptable"
		workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Head
		workspace.CurrentCamera.CoordinateFrame = CFrame.new(workspace.CameraPart.Position, game.Players.LocalPlayer.Character.Head.Position)
		game:GetService('RunService').RenderStepped:wait()
	end
end

local function off()
	inuse = false
	game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
	game.Workspace.CurrentCamera.CameraType = "Custom"
end

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.Four and debounce == true then
		on()
		debounce = false
	elseif debounce == false then
		off()
		debounce = true
	end
end)

Do you receive any console errors when launching the game in studio?

Hold on, let me check.

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

No, however I received a warning.
14:49:52.966 ActivateCameraController did not select a module.

The function named “on” contains a while loop which runs infinitely (no specified breaking point), meaning that in the following:

on()
debounce = false

on() never completes and as such the variable named “debounce” is not set to false.

I believe this is what the issue is.

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.Four then
		if debounce == true then
			debounce = false
			on()
		elseif debounce == false then
			debounce = true
			off()
		end
	end
end)

No that’s most likely not the issue. The problem is that the function on() doesn’t stop since it’s in a while loop so the next line (where you set the debounce to false) will never be executed.

If you didn’t saw, this breaks the loop.

This makes the loop infinite, not the opposite…

inuse is always true meaning that the while loop cycles forever.

inuse = true
while inuse == true do

Is essentially the same as:

while true do

What you need is at some point set inuse to something other than true. For instance (nil or false).

It should, but it won’t. Because inuse will never be false as the debounce will also never be false - which prevents off() from running.

Thank you this works!

Summary

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Glad to be of use, but if you will, please mark Limited_Unique’s reply as the solution because I only wanted to explain his answer.

1 Like