How to allow Proximity prompt to continuously be activated while holding down the activation key?

I’m making a zombie game where you board up windows, and I’m using the proximity prompt to place a plank.

The problem is whenever the player places planks, the player has to release and press the activation key every time the player wants to place a plank, instead of holding a key the entire time.

I couldn’t find anything in the dev forums.

Here’s how I’m detecting input right now:

--Detect if interaction
self.buildPrompt.Triggered:Connect(function(plr)
		
	self:Place(plr)
		
end)

Thanks

The proximity prompt has 2 events: ProximityPrompt.Triggered and ProximityPrompt.TriggerEnded. Unlike Triggered, which is fired when the prompt completes the Hold Duration, TriggerEnded is only fired when the Player stops pressing the prompt.

You can use this to create a loop that performs the desired action, as shown in the example:

local Prompt = script.Parent

Prompt.Triggered:Connect(function(Player)
	local Pressing = true

	Prompt.TriggerEnded:Once(function()
		Pressing = false
	end)
	
	repeat 
		-- Your code here
		
		task.wait()
	until not Pressing
	
	print("Stoped Pressing")
end)
1 Like

Do you know how to show the activation UI every time? Because it will only show after the first activation, thanks

I’m not sure if there’s a way to do that; I looked in the proximity prompt API and didn’t find anything related. If you want to take a look, here’s the proximity prompt API:

1 Like

Have you tried increasing the duration of the prompt?

That isn’t what the OP is asking. He’s asking how to show the activation UI every time and have the callback be ran multiple times.

You could try scripting your own proximity prompt using this linked resource’s UI:

You could try to dig around for where the activation UI and trigger event is fired, so you can more easily make yours fit Roblox’s effect. Every time you want it to activate, call that, and run your callback.

1 Like