ProximityPrompt fires twice .Triggered event

local Prompt = Instance.new("ProximityPrompt")
Prompt.ActionText = "Open"
Prompt.ObjectText = "Door"
Prompt.RequiresLineOfSight = false
Prompt.Triggered:Connect(function()
	print(script:GetFullName(), script)
end)
Prompt.Parent = Handle

Prints this when I press E.

Workspace.1113.House.Door.4674 4674
Workspace.1113.House.Door.4674 4674

But why? I have been trying to fix this for over 2 hours. I did randomize the name of the script to check if there is two different numbers but it seems like its caused by one script and that this is not caused by duplication.

This only happens when I clone a model and then attach a script to it.

1 Like

Why not add a debounce to check if the prompt had already been triggered?

What’s the point of that? .Triggered event should only fire once when I am pressing E once.

I tried and it worked but still, this should not be happening. I suspect that Roblox did something accidently and made their event fire twice.

1 Like

You are gonna have to use prompt service itself

Why, also here is more…

local c = game:GetService("CollectionService")

c:GetInstanceAddedSignal("a"):Connect(function(b)
	local a = script.ModuleScript:Clone()
	a.Parent = b
	require(a)
end)

local part = game.ServerStorage.Part:Clone()
part.Parent = workspace

this code is causing this problem but i am not sure why

Still, it may trigger twice, you never know if the debounce can solve your problem.

1 Like

Also, if it is Roblox’s issue, what can you do about it other than implementing your own fix first?

I do know, but normally it triggers once, but as soon as I use collection service it does the duplicate glitch.

I’ll try to reproduce the bug later, if it works then you might have to report this to #bug-reports.

Can you explain why you are using collection service? Also, I would suggest giving more descriptive names to your variables using names like “a” and “b” is bad practice.
Edit: I tested your first script and the triggered even only fired once for me.

Yea it should work it happened to me.

Because I have multiple doors.

This was only meant for the issue reproduction place.

It did because you didn’t do what I did in my place. So here is the repro file of the issue: WillTriggerTwice.rbxl (30.2 KB)

Thanks for the file. I’ll take a look right now.
Edit: So, I took a look into it and I couldn’t find any reason for it to trigger twice. The method your using to add the proximity prompt doesn’t make much sense. I would suggest adding it on the collection service event and connecting the event there. You’re making a module script for each part and using the fact that requiring the module script runs the code inside it. But, in the end this does seem like a bug.

1 Like

Indeed, that’s what I was trying to prove, it is not what I expected it to do. Should I mention Roblox staff here? As this issue is really unexplainable to me.
image

You can make a bug report in #bulletin-board and ask for it to be moved. I’m just going to check this one more time to confirm it. I couldn’t replicate this, I think I’m just missing something.

1 Like

You define Prompt
Then you call Prompt

It prints once at definition; once at the call.

Could you explain more? I don’t understand what you’re saying.

Follow your program flow:
1 + 1 = 2

From what I understand a part is cloned and parented to workspace which causes “InstanceAdded” to be fired from collection service since the part has a tag. Then, a proximity prompt is added to it through a module script parented to the part. This module script connects to the triggered event of the proximity prompt, which in theory should only fire once. I probably am being dumb, but I just don’t get what’s causing it.

me neither.

Here’ another idea:

print(script:GetFullName())