Custom Proximity Prompts

Hey! So I’ve just gotten back into studio after a while break. I just saw proximity prompts and was intrigued. I started on my own custom one, but I have no idea how to make it activate on click (or keypress).

The GUI pops up after you are at a certain distance and once you are hovering over it. image

Here is my code.
image

Please keep in mind that it is not printing.

1 Like

I think you forgot to add this when making your own proximity prompt style
For more details, visit:
https://developer.roblox.com/en-us/api-reference/property/ProximityPrompt/Style

button.InputBegan:Connect(function(input)
			if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
				input.UserInputState ~= Enum.UserInputState.Change then
				prompt:InputHoldBegin()
				buttonDown = true
			end
		end)
		button.InputEnded:Connect(function(input)
			if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
				if buttonDown then
					buttonDown = false
					prompt:InputHoldEnd()
				end
			end
		end)

If you’re making your own custom proximity prompts you can use context action service to bind keys onto functions when a player gets within a certain distance, and then unbind when they are outside of this set distance. And as for clicking, you can use a surface GUI with a TextButton or an ImageButton.

Im using the proximity prompt instance, I just want to customized the GUI

what would the “button” variable be in this case?

If the ProximityPrompt.Style is Custom, you have to provide a InputBegan and InputEnded.
If you are looking for a tutorial, go check this. It’s really helpful.

I think that the InputBegan in only for mobile. Is there a way to make the prompt run code when I press the keyboard button?

Did you add an HoldDuration? It will not work if it doesn’t have a duration in it.

1 Like

after a bit of testing, I tried a default proximity prompt.
this is my code -


It never triggers.

But it prints out? I’m assuming it’s something about parenting the gui to the player.

Here’s my modified script.

local proxService = game:GetService("ProximityPromptService")

proxService.PromptTriggered:Connect(function(prompt, p)
    print("Prompt Triggered")
    local pg = p.PlayerGui.ProxPrompts
    local s, e = pcall(function()
        for _, v in pairs(pg:GetChildren())
        v:Destroy()
    end)
    
    local gui = game.ReplicatedStorage.Guis[script.Parent.Parent.Name]:Clone()
    gui.Parent = p.PlayerGui
end)

it does not print out (character limit)

I’m super stupid. I used a LocalScript instead of a Script. Sorry! Thank you @ZacharyZaxorDDD for the help tho

3 Likes