So When i press M and hold it down for the period of time it fires the Use Remote but after i press M again it keeps firing the Use Remote and not the Stop Remote

local PlayerService = game:GetService("Players")
local UserInputService = game:GetService("UserInputService") -- Using UserInputService instead of mouse.

local Client = PlayerService.LocalPlayer

local Key = "M" -- The ke the person has to hold

local Holding = false -- Detects when the key is being held
local ExpectedHold = 3 -- How long you want the player to be hold the key for
local HoldingTime = 0 -- The amount of seconds they holded for
local Replicated = script.Parent
local Event = Replicated:WaitForChild("Use")
local Deactivate = Replicated:WaitForChild("Stop")

UserInputService.InputBegan:Connect(function(Input, GPE)
    if not GPE then
        if Input.KeyCode == Enum.KeyCode[Key] then -- When they start to press the key this runs
            if not Holding then -- if they arent already holding then it continues
                Holding = true -- Makes holding true/script now knows they're holding the key

                while Holding do wait(1) -- Basically while holding == true the code after this will run every second
                    if HoldingTime < ExpectedHold then
                        HoldingTime = HoldingTime + 1 -- This adds to how long they holder the key for
                    end
                end
            end
        end
    end
end)


UserInputService.InputEnded:Connect(function(Input, GPE) -- runs when they stop holding a key
    if not GPE then
        if Input.KeyCode == Enum.KeyCode[Key] then
      Holding = false
            if HoldingTime >= ExpectedHold then -- if they holding the key for the right amount of time
                Event:FireServer() -- fires the remote if they did
            else
                print(Client.Name..' holded '..Key..' for '..HoldingTime..' second(s).')
                HoldingTime = 0 -- sets the time back to 0
            end
        end
    end
end)