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.
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.
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.
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)