ProximityPrompt.Triggered being fired multiple times

Anytime PromptButtonHoldBegan and PromptButtonHoldEnded are fired, it adds to the amount of items my script gives to the player, why?

prompt.PromptButtonHoldBegan:Connect(function(plr_search)
			local search_chr = plr_search.Character
			local hum = search_chr:FindFirstChildOfClass("Humanoid")
			hum.WalkSpeed = 0
			looting_event:FireClient(plr_search,true)
			prompt.PromptButtonHoldEnded:Connect(function()
				looting_event:FireClient(plr_search,false)
				hum.WalkSpeed = 12
				return
			end)
			prompt.Triggered:Connect(function()
				if search_chr:FindFirstChildOfClass("Tool") then
					search_chr:FindFirstChildOfClass("Tool").Parent = plr_search.Backpack
				end
				local inventory_slots = #plr_search.Backpack:GetChildren()
				if inventory_slots ~= 4 then
					print("searched container")
					local gotitem
					for _, item in pairs(spawns) do
						if gotitem == nil then
							local itemchance = item:GetAttribute("chance")

							if math.random(1,100) <= itemchance then
								item:Clone().Parent = plr_search.Backpack
								gotitem = item.Name
							end
						end
					end
					founditem_event:FireClient(plr_search,gotitem)
					prompt.Enabled = false
				else
					founditem_event:FireClient(plr_search)
					print("inventory full")
				end
			end)
		end)

update:
Issue was just the layering of functions, weird considering I’ve never experienced this

Mark the message as a solution, to close the support.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.