do local Q=false local function x()if Q then StopFreecam()else StartFreecam()end Q=not Q end local function H(Q)for x=1,#Q-1,1 do if not UserInputService:IsKeyDown(Q[x])then return end end x()end local function q(Q,q,E)if q==Enum.UserInputState.Begin then if E.KeyCode==FREECAM_MACRO_KB[#FREECAM_MACRO_KB]then H(FREECAM_MACRO_KB)end if E.KeyCode==Enum.KeyCode.F then x()end end return Enum.ContextActionResult.Pass end ContextActionService:BindActionAtPriority("\070\114\101\101\099\097\109\084\111\103\103\108\101",q,false,TOGGLE_INPUT_PRIORITY,FREECAM_MACRO_KB[#FREECAM_MACRO_KB])ContextActionService:BindActionAtPriority("\070\114\101\101\099\097\109\084\111\103\103\108\101\050",q,false,TOGGLE_INPUT_PRIORITY,Enum.KeyCode.F)RF.OnClientInvoke=function(H,q,E)if H=="\068\105\115\097\098\108\101"and Q then Q=false StopFreecam()end if H=="\069\110\097\098\108\101"and not Q then Q=true StartFreecam()end if H=="\084\111\103\103\108\101"then x()end if H=="\069\110\100"or H=="\083\116\111\112"then RF.OnClientInvoke=nil Debris:AddItem(RF,.5)StopFreecam()end end x()end
------------------------------------------------------------------------

do
	local enabled = false

	local function ToggleFreecam()
		if enabled then
			StopFreecam()
		else
			StartFreecam()
		end
		enabled = not enabled
	end

	local function CheckMacro(macro)
		for i = 1, #macro - 1 do
			if not UserInputService:IsKeyDown(macro[i]) then
				return
			end
		end
		ToggleFreecam()
	end

	local function HandleActivationInput(action, state, input)
		if state == Enum.UserInputState.Begin then
			if input.KeyCode == FREECAM_MACRO_KB[#FREECAM_MACRO_KB] then
				CheckMacro(FREECAM_MACRO_KB)
			end

			if input.KeyCode == Enum.KeyCode.F then
				ToggleFreecam()
			end
		end
		return Enum.ContextActionResult.Pass
	end

	ContextActionService:BindActionAtPriority(
		"FreecamToggle",
		HandleActivationInput,
		false,
		TOGGLE_INPUT_PRIORITY,
		FREECAM_MACRO_KB[#FREECAM_MACRO_KB]
	)
	ContextActionService:BindActionAtPriority(
		"FreecamToggle2",
		HandleActivationInput,
		false,
		TOGGLE_INPUT_PRIORITY,
		Enum.KeyCode.F
	)

	RF.OnClientInvoke = function(a, b, c)
		if a == "Disable" and enabled then
			enabled = false
			StopFreecam()
		end

		if a == "Enable" and not enabled then
			enabled = true
			StartFreecam()
		end

		if a == "Toggle" then
			ToggleFreecam()
		end

		if a == "End" or a == "Stop" then
			RF.OnClientInvoke = nil
			Debris:AddItem(RF, 0.5)
			StopFreecam()
		end
	end

	ToggleFreecam() -- Runs the freecam automatically
end
