Setting ProximityPrompt.Enabled = false after it has been triggered will cause the prompt to flicker weirdly. This flickering behavior doesn’t look too bad if Enabled is set to false immediately after the trigger, but waiting longer after the trigger before setting Enabled to false will make the flicker look worse.
Here is a video of the flickering behavior (first = no flicker which is the desired behavior, second = tolerable flicker, third = ugly flicker):
Repro (LocalScript in StarterPlayerScripts):
local part = workspace:WaitForChild("SpawnLocation")
-- This prompts won't flicker after trigger. (First prompt in the video.)
do
local p = Instance.new("ProximityPrompt")
p.Parent = part
p.HoldDuration = 0.5
p.MaxIndicatorDistance = 50
p.Triggered:Connect(function()
-- do nothing.
end)
end
-- This prompt will flicker after trigger. (Second prompt.)
do
local attach = Instance.new("Attachment")
attach.Position = Vector3.new(0, 0, 10)
attach.Parent = part
local p = Instance.new("ProximityPrompt")
p.Parent = attach
p.HoldDuration = 0.5
p.MaxIndicatorDistance = 50
p.Triggered:Connect(function()
p.Enabled = false
-- re-enable later
task.wait(2)
p.Enabled = true
end)
end
-- This prompt will flicker after trigger, even worse. (Third prompt.)
do
local attach = Instance.new("Attachment")
attach.Position = Vector3.new(0, 0, 20)
attach.Parent = part
local p = Instance.new("ProximityPrompt")
p.Parent = attach
p.HoldDuration = 0.5
p.MaxIndicatorDistance = 50
p.Triggered:Connect(function()
task.wait()
task.wait()
task.wait()
task.wait()
p.Enabled = false
-- re-enable later
task.wait(2)
p.Enabled = true
end)
end