How do I change a gyro to only play when I activate my fly script?

So I’m having a problem, basically in another post, it told me to use a gyro fro my fly script, to make the animation follow my cursor, but now the gyro is always playing, so the walking animation is playing, but it’s playing where I move my cursor to. https://imgur.com/a/b5G01D5

repeat wait() until (game.Players.LocalPlayer.Character:WaitForChild("Humanoid") ~= nil)
local animObj = Instance.new("Animation")
animObj.AnimationId = "rbxassetid://" .. id
local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animObj)
anim.Looped = true
local player = game.Players.LocalPlayer
if not player.Character then player.CharacterAdded:Wait() end
local char = player.Character
local Hrp = char:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local BV = Instance.new("BodyVelocity",character:WaitForChild("HumanoidRootPart"))
local speed = 100
local Bind = false
local UIS = game:GetService("UserInputService")
local gyro = Instance.new("BodyGyro")

gyro.Parent = Hrp
gyro.MaxTorque = Vector3.new(0,math.huge,0)
gyro.P = 6000

UIS.InputChanged:connect(function()
	gyro.CFrame = CFrame.new(Hrp.CFrame.p,mouse.Hit.p)
end)

BV.MaxForce = Vector3.new()
UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F and not Bind then
        Bind = true
        BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
          anim:Play()
    elseif input.KeyCode == Enum.KeyCode.F and Bind then
        Bind = false
        BV.MaxForce = Vector3.new()
        anim:Stop()
    end
end)
UIS.InputChanged:Connect(function()
BV.Velocity = CFrame.new(character.HumanoidRootPart.Position,mouse.Hit.Position).LookVector * speed
end)```