Hold button down to keep door down?

I need help trying to figure out a script that if you hold a button down (proximity prompt) it keeps a door closed but you can only keep it open for a certain amount of time until a cool down.

I have been trying to figure it out for a while and can’t seem to figure out a way to make it work.

Can someone help me make a script for it?

Roblox Rule of Scripting Support

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Three Blocks:

  1. What do you want to achieve? Keep it simple and clear!
  2. What is the issue? Include screenshots / videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the

I dont think the 3 Blocks matter. just the first rule

Even considering the rules of scripting support, I’ll still help. The general structural development procedure would be

  • Proximity Prompt: (HoldDuration = Time)
  • When time lasts, move proximity prompt (ReplicatedStorage, most likely)
  • Return it after cooldown

You could also disable it when the time lasts, as it does have an Enabled boolean.

If you can’t answer the three questions above

The three blocks were the three questions, I just listed them just in case.

I’m not a scripter so I need help with making a script to make it work

I’ve tried looking all over the dev forums and youtube and have not found anything that can help me

local ProximityPrompt = script.Parent:WaitForChild("ProximityPrompt")
local CooldownTime = 5 -- Seconds

local function Disable()
	ProximityPrompt.Enabled = false
	ProximityPrompt.Enabled = true
	print("close door")


	print("open door")

	print("close door")

Set the HoldDuration(->ProximityPrompt) to affect how long they can hold it, and the cooldown time is how long until they can press it again.

1 Like

In the proximity prompt documentation, there are events you can use to accomplish this task.
You can use PromptButtonHoldBegan and PromptButtonHoldEnded to know when the player is holding or releasing the prompt.

Nothing is really happening and nothing popping up in the output

If you put the script in a part with a (try adding a new?) proximity prompt in it, it does work as I have tried it myself.

nvm i got it to work, I had the script in the proximity prompt lol

It’s great that you have it working now! To help show that your post is irrelevant now, could you please mark my answer as the solution? Not only does it help me, but it also helps clean up the category :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.