How To | Converting a momentary button to a trigger using Lua scripting

Convert a momentary button to a trigger using Lua scripting

Updated at October 13th, 2023

Your engagement helps us create the content you need. Click here to review this article.



Table of Contents

Procedure


This function will convert the momentary button press into a triggered output. 

  1. Drag a Text Controller into the design.
  2. Open the component
  3. Add two controls
  4. Set one of the controls to a "Momentary" button, and name it “Btn”
  5. Set the other control be be a "Trigger" button. and name it “Trigger"
  6. Open the script editor and copy the code snippet into it
Component.New("Test")["Btn"].EventHandler = function() --This line captures the state change of the button press and runs function 

	if Component.New("Test")["Btn"].Boolean == true then --This line looks at the button presses state to determine if true or not 

		Component.New("Test")["Trigger"]:Trigger() --this line sets Trigger output  

	end
end