Interrupting character movement while interacting with UI objects

I was wondering if it was possible to only run the following script when the player is not interacting with UI objects. The following script is supposed to move the player’s head and torso based on the user’s mouse movement. Any suggestions are appreciated.

(Script not mine, I only edited it to suit my needs)

RunService.RenderStepped:Connect(function()
	if Body["UpperTorso"] ~= nil and Body["Head"] ~= nil then	
		local TrsoLV = Trso.CFrame.lookVector
		local HdPos = Head.CFrame.p
		if Neck and Waist then	
			if Camera.CameraSubject:IsDescendantOf(Body) or Camera.CameraSubject:IsDescendantOf(Player) then
				local dS = nil;
				local dF = nil;
				local Point = Mouse.Hit.p
				dS = (Head.CFrame.p-Point).magnitude
				dF = Head.CFrame.Y-Point.Y
				Neck.C0 = Neck.C0:lerp(NOC0*Angles(-(Tan(dF/dS)*HVF),(((HdPos-Point).Unit):Cross(TrsoLV)).Y*HHF,0),US/2)
				Waist.C0 = Waist.C0:lerp(WOC0*Angles(-(Tan(dF/dS)*BVF),(((HdPos-Point).Unit):Cross(TrsoLV)).Y*BHF,0),US/2)	
			end
		end
	end
	Hum.AutoRotate = true
end)

Hi! Yeah, it can be. Try something like this:

local variable = script.BoolValue.Value

while variable == true do --If they click on the button, this variable can be false
RunService.RenderStepped:Connect(function()
	if Body["UpperTorso"] ~= nil and Body["Head"] ~= nil then	
		local TrsoLV = Trso.CFrame.lookVector
		local HdPos = Head.CFrame.p
		if Neck and Waist then	
			if Camera.CameraSubject:IsDescendantOf(Body) or Camera.CameraSubject:IsDescendantOf(Player) then
				local dS = nil;
				local dF = nil;
				local Point = Mouse.Hit.p
				dS = (Head.CFrame.p-Point).magnitude
				dF = Head.CFrame.Y-Point.Y
				Neck.C0 = Neck.C0:lerp(NOC0*Angles(-(Tan(dF/dS)*HVF),(((HdPos-Point).Unit):Cross(TrsoLV)).Y*HHF,0),US/2)
				Waist.C0 = Waist.C0:lerp(WOC0*Angles(-(Tan(dF/dS)*BVF),(((HdPos-Point).Unit):Cross(TrsoLV)).Y*BHF,0),US/2)	
			end
		end
	end
	Hum.AutoRotate = true
end)
end