How to make a proximity prompt hold duration not reset after removing finger from the key

Im trying to make a door that opens as long as you hold on the proximity prompt key. for example if you hold on the proximity prompt key for longer it will open more, and if you hold it for less time it opens less.

The problem I ran into is that if you lift your finger off the proximity prompt before it triggers and press it again it will start from the beginning.

I’ve searched through proximity prompts properties and searched the dev forum for anything that could help but i couldnt find much.

Im thinking i could fix this problem if I knew how much time has elapsed before the player lifts his finger on the proximity prompt but i couldnt find out how. Any help will be appreciated.

You could use the InputHoldBegin and InputHoldEnded events from the ProximityPrompt to see how long the door should be opened for. The way I’d go about it is storing the current tick upon the input starting, and getting the tick when it ends. then I would do (START_TIME - END_TIME) / <int> to calculate the time the door would be opened for.

If you don’t want the progress bar to reset, normally ProximityPrompts don’t behave like this, so you will probably need to add your own UI to the prompt plus the neccessary scripts.

There is a rather lengty example of how to do that in de PromptButtonHoldEnded docs.

For a simpler example, that might do something much easier but perhaps similar to you want to do, see the TriggerEnded docs.

If finding the duration that the button was pressed is all you need, @Benified4Life’s suggestion should work, except InputHoldBegin and InputHoldEnded are the functions to manually start holding, the event names they undoubtedly mean are PromptButtonHoldBegan and PromptButtonHoldEnded.