ProximityPrompt disconnects .Triggered() after using :Clone()

This is originally intended for bug reports.
Sadly I can’t submit it to that forum yet.

A detailed description
When you use :Clone() on a model containing a ProximityPrompt the function that the ProximityPrompt should fire does not clone along.

How to replicate the bug
Start with an empty baseplate
Add a script and a part with a ProximityPrompt

afbeelding
In the image bove. the blue arrow points to the script and the red arrow to the ProximityPrompt that we want to clone

The code to insert into the script is:

script.Parent.promt.ProximityPrompt.Triggered:Connect(function()
	print("It works")
end)

local new = script.Parent.promt:Clone()

new.Position=Vector3.new(0,10,0)
new.Parent=workspace

When walking to the original part and triggering the ProximityPrompt it will output “It works”

When walking to the cloned part and triggering the ProximityPrompt it does nothing.

You should put the script in the part that contains Porximity, so that the script gets cloned too

script.Parent.promt:SetAttribute("PromptType1", true)

local function listenTrigger(Proximity:ProximityPrompt)
	if Proximity:GetAttribute("PromptType1") then
		Proximity.Triggered:Connect(function()
			print("It works")
		end)
	end
end
listenTrigger(script.Parent.promt.ProximityPrompt)
game.Workspace.DescendantAdded:Connect(listenTrigger)

local new = script.Parent.promt:Clone()

new.Position=Vector3.new(0,10,0)
new.Parent=workspace

This probably isn’t working because you duplicate the part “prompt”, making it have 2 parts with the same name.

My guess is, it’s actually listening for the ProximityPrompt in the old part, not the duplicated one.

i connect the trigger before the clone() not after

@NicoleSydor
yes that was the workaround I now implemented
it works but the bug is still in-game

@ryanhawari17 in the example that is doable. yet in my current situation it is not.
after cloning the ProximityPrompt i reconnect the triggered event

If you want that same function to run every time you trigger a ProximityPrompt (any proximity prompt), just remove this condition and listenPrompt to every ProimityPrompt.

New Script
local function listenTrigger(Proximity:ProximityPrompt)
    Proximity.Triggered:Connect(function()
		print("It works")
	end)
end
for _, proximity:ProximityPrompt in pairs(game.Workspace:GetDescendants()) do
    listenTrigger(proximity)
end
game.Workspace.DescendantAdded:Connect(listenTrigger)

local new = script.Parent.promt:Clone()

new.Position=Vector3.new(0,10,0)
new.Parent=workspace