How To | Converting a momentary button to a trigger using Lua scripting
Convert a momentary button to a trigger using Lua scripting
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.
- Drag a Text Controller into the design.
- Open the component
- Add two controls
- Set one of the controls to a "Momentary" button, and name it “Btn”
- Set the other control be be a "Trigger" button. and name it “Trigger"
- 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