You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I would like some help seeing what is wrong with my current code making a ProximityPrompt fire twice. -
What is the issue? Include screenshots / videos if possible!
Upon firing the prompt the first time it works just fine, but once I fire it a second it creates 2 clones, 3 for the third trigger and so forth -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried fully rewriting the code but that didn’t fix anything. Neither did adding a debounce like another person’s topic suggested.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local doughMaker = script.Parent
local promptPart = doughMaker.PromptPart
local building1 = doughMaker.Parent
local bakery1 = building1.Parent
local owner = bakery1.Owner
local ingredientsFolderSS = ServerStorage:WaitForChild("Ingredients")
local toolsFolder = ServerStorage:WaitForChild("Tools")
local ingredientTools = toolsFolder:WaitForChild("Ingredients")
local DB = false
doughMaker.PromptPart.ProximityPrompt.Triggered:Connect(function(player)
if DB == false then
DB = true
if player.Name == owner.Value then
local mainGUI = player.PlayerGui:WaitForChild("MainGui")
local doughGUI = mainGUI:WaitForChild("DoughMenu")
local leftSideButtons = mainGUI:WaitForChild("LeftSideButtons")
local closeButton = doughGUI:WaitForChild("Close")
leftSideButtons.Visible = false
doughGUI.Visible = true
for i, v in pairs(doughGUI.Buttons:GetChildren()) do
if v:IsA("Frame") then
if building1.Recipes:FindFirstChild(v.Name) then
v.Visible = true
v.Button.MouseButton1Click:Connect(function()
doughMaker.PromptPart.ProximityPrompt.Enabled = false
doughGUI.Visible = false
local newOBJ = ingredientsFolderSS:FindFirstChild(v.Name)["1"]:Clone()
newOBJ.Name = "OBJ"
newOBJ.Position = doughMaker.Bottom.Position - Vector3.new(0,0.5,0)
local newPrompt = Instance.new("ProximityPrompt")
newPrompt.ObjectText = "Pick up"
newPrompt.ActionText = "Dough"
newPrompt.HoldDuration = 1
newPrompt.Parent = newOBJ
print("fired")
newOBJ.Parent = doughMaker
leftSideButtons.Visible = true
newPrompt.Triggered:Connect(function(player2)
if player2.Name == owner.Value then
local newTool = ingredientTools:FindFirstChild(v.Name.." dough"):Clone()
newTool.Parent = player.Backpack
doughMaker.PromptPart.ProximityPrompt.Enabled = true
newOBJ:Destroy()
end
end)
end)
end
end
end
closeButton.MouseButton1Click:Connect(function()
doughGUI.Visible = false
end)
end
wait(.25)
DB = false
end
end)