Button animation (.gif) for touchbar

Thanks @Cesar_Pasache!!!

Got it to work, however. the .gif is always on and I would like it to be static until pressed.

Below is the script I am using. Let me know if you can recommend anything. Thanks!

tell application "BetterTouchTool"

set numFrames to 3

set startFrame to 0

set basePath to "/Users/mannyo/Documents/"

set baseName to "spaceinvader2-"

set extension to ".png"

uuid - https://docs.bettertouchtool.net/docs/apple_script.html

set widgetId to "4C36DFF3-850E-4DFF-9DC1-E4F433AFB1F4"

set varName to "anim-" & baseName & "frame"

try

set frame to (( get_number_variable varName) as integer )

on error

set frame to startFrame

end try

if frame > numFrames then

set frame to startFrame

end if

set_persistent_number_variable varName to frame + 1

set fileName to baseName & (frame as string ) & extension

set fullFilePath to basePath & fileName

update_touch_bar_widget widgetId text " " icon_path fullFilePath

end tell