Why does a function running multipe times in one use?

I want to make a script that would instance a seat when u triggering a proximityprompt,and it works perfectly in first time,but there will be multipe seats instanced in second trigger…

Here is some simpfied code:
#Lua#
local plrservice = game:GetService(“Players”)
local collectionservice = game:GetService(“CollectionService”)

for i,v in pairs(TableWithChair) do
for i,d in pairs(v:GetChildren()) do
if d.Name == “One” then

  d:FindFirstChild("Proximity").ProximityPrompt.Triggered:Connect(function(player)
			d:FindFirstChild("Proximity").ProximityPrompt.Enabled = false

local SeatInstance = Instance.new("Seat")
				SeatInstance.Parent = d:FindFirstChild("Proximity")
				SeatInstance.CFrame = d:FindFirstChild("Proximity"):FindFirstChild("SitPos").CFrame
				SeatInstance.Transparency = 1
				SeatInstance.Size = Vector3.new(2.25,0.05,2)
				d:FindFirstChild("Proximity"):FindFirstChild("WeldSeat").Part1 = SeatInstance
				d:FindFirstChild("Proximity"):FindFirstChild("WeldSeat").Part0 = d:FindFirstChild("Proximity")

#Lua#

1 Like

That should fire every time the player triggers the ProximityPrompt, consider switching to ProximityPromptService instead of CollectionService to handle multiple prompts.

I think you need to use Debounce?

I just looked up for the APIs of proximitypromptservice,but they actually make me confused,could u tell me some easier method or gimme some example please?

It does not move,i think its because it fires more then one time in one use,but not repeating in one use.