when I Press Space Bar 2 times my flying script activates

but I flys in the cam's position by itself! I want it to activated but not fly by itself and fly towards the camera's look vector when the character "Moves"

Why doesn't that happen

btw you can copy this script and test it your self too...….

local play = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local char = play.Character
local hum = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
local inair = false
local canjump = true
local moving = true
local cam = game.Workspace.CurrentCamera
local flying = false
hum.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Freefall or new == Enum.HumanoidStateType.Jumping then
		inair = true
		
	else
		inair = false
		canjump = true
	end
	end)


uis.InputBegan:Connect(function(input)
	
	if input.KeyCode == Enum.KeyCode.Space and inair == true and canjump == true then
	print("falsenow")	
	canjump = false	
	local bv = Instance.new("BodyVelocity",char.HumanoidRootPart)
	
   flying = true
								
	bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	hum.StateChanged:Connect(function(old,new)
		if new == Enum.HumanoidStateType.Running then
			if flying == true  then
			moving = true
		else
			moving = false
			end
		 end
	end)		
	while moving == true do wait()
		if moving == false then
		bv.Velocity = cam.CFrame.LookVector * 0
			
		end
		bv.Velocity = cam.CFrame.LookVector * 100
		
		 
		end
	bv:Destroy()
flying = false
	
	---print("fly")
	


	end
end)