How would you make a button that keeps a door open while you are keeping you mouse clicked on it but if you release your mouse the door closes

  1. What I want to achieve: I want to have a door that stays open only while you have your mouse held onto the button and closes when you take your mouse off of the button

  2. What I have tried: I have tried using input ended and input began but I could not figure out how to fit that into my current door script
    Here’s the script:
    Screenshot 2022-07-23 234654|596x500

  3. I have tried to look through the developer hub and through youtube as well but could not find anybody else with the same problem as me.

Conclusion: I want to create a door with a click detector button that makes the door open while you are holding your mouse on the button but once you take your mouse off the button the door closes.

any help is appreciated thank you! (I am also new to scripting and new to posting on the devforums so please excuse any mistakes i may have made)

1 Like

You can use InputBegan to open it and InputEnded to close it

Use

Button.MouseButton1Down

And

Button.MouseButton1Up

thanks for the reply guys! but how exactly would i put those into my current script?

1 Like

I recommend you to Google the devhub and read a bit, it will solve a lot of your problems!

MouseButton1Up: Mouse.Button1Up
MouseButton1Down: Mouse.Button1Down

1 Like

Okay thank you guys! Appreciate all of the help!

I am here if any doubt appears :slight_smile:

Yessss thank you I accomplished my goal

1 Like