UserInputService.InputBegan only firing once?

why does this only work once then just stop, no errors

toggled = true
tweens = {notToggled = UDim2.new(-1.5,0,0.5,0), toggled = UDim2.new(0.5,0,0.5,0)}
game:GetService("UserInputService").InputBegan:connect(function(input, Processed)
    if not Processed then
        if input.KeyCode == Enum.KeyCode.M then --a PC key was pressed
            if toggled then
                toggled = false
                script.Parent.Frame:TweenPosition(tweens.notToggled,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,0.5)
            end
            if not toggled then
                toggled = true 
                script.Parent.Frame:TweenPosition(tweens.toggled,Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.5)

            end
        end
    end
end)

The if not statement was running immediately after the if statement - it should have been an elseif not instead,

if toggled then
	toggled = false
	script.Parent.Frame:TweenPosition(tweens.notToggled,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,0.5)
else
	toggled = true 
	script.Parent.Frame:TweenPosition(tweens.toggled,Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.5)
end

You also have the else statement too.