This seems to be an issue with how ProximityPromptService handles the PromptShown event. It triggers once again when, as you reported, changing input types.
local function onLoad()
ProximityPromptService.PromptShown:Connect(function(prompt, inputType)
print(inputType)
if prompt.Style == Enum.ProximityPromptStyle.Default then
return
end
local gui = getScreenGui()
local cleanupFunction = createPrompt(prompt, inputType, gui)
-- Wait for either the prompt being hidden or destroyed
local yield = Instance.new("BindableEvent")
local con = prompt.PromptHidden:Connect(function()
yield:Fire()
end)
local con2 = prompt.Destroying:Connect(function()
yield:Fire()
end)
yield.Event:Wait()
con:Disconnect()
con2:Disconnect()
cleanupFunction()
end)
end
onLoad()
Interestingly enough this also creates an unused-past-usage BindableEvent. Cumbersome!
This is intentional behavior.
The way to customize a ProximityPrompt is to listen to the ProximityPrompt.PromptShown and ProximityPrompt.PromptHidden events to show/hide your prompt with the appropriate input type. When input changes, this will in fact clear the old one and create a new one.
There is no API to allow an existing prompt UI to modify from, say, keyboard input to gamepad input. If such an API did exist, it would need to be something like this:
ProximityPrompt.InputTypeChanging
In addition to writing the initial code to create the UI, developers would need to handle every switch between all input types. This introduces additional complexity and would be a burden on developers customizing UI, which could lead to errors.
We believe the additional complexity here is not worth the minimal performance gain.
From my testing though, changing any property to the ProximityPrompt doesn’t create a new UI. So you still have to listen for these changes to update your custom UI appropriately anyway?