How to get the certain prompt being triggered

How can I get the exact prompt that is being triggered, I have multiple that do the same job, the script makes it so that the prompt that was triggered is destroyed but instead of destroying the one that was triggered, another prompt was destroyed.

function Janitor:Init(Player)
	
	if self.Shack.Employee.Team == Teams.Janitor then
		local staffTools = game.ServerStorage.StaffTools.Janitor
		local mopCloned = staffTools.Mop:Clone()
		mopCloned.Parent = self.Shack.Employee.Backpack
		
	end
	
	game.Workspace.ChildAdded:Connect(function()
		for i, instance in pairs(game.Workspace:GetChildren()) do
			if collectionService:HasTag(instance, "Janitor") then
				self.Prompt = instance:WaitForChild("Proximity")
			end
		end
		
		self.Prompt.Triggered:Connect(function(...)
			self:PromptClick(..., self.Prompt)
		end)
	end)
end

function Janitor:PromptClick(player, prompt)
	
	print(prompt.Name)
	prompt:Destroy()
	
	local questionsUi = script.Parent.Parent.Functions.Math.MathQuestion
	local playerGui = player:WaitForChild("PlayerGui")
	local newMathQuestion = questionsUi:Clone()
	newMathQuestion.Parent = playerGui

end

Try returning the promptβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Žβ€Ž β€β€β€Ž

1 Like

The return doesnt work, the same issue occurs unfortunately

function Janitor:Init(Player)
	
	if self.Shack.Employee.Team == Teams.Janitor then
		local staffTools = game.ServerStorage.StaffTools.Janitor
		local mopCloned = staffTools.Mop:Clone()
		mopCloned.Parent = self.Shack.Employee.Backpack
		
	end
	
	game.Workspace.ChildAdded:Connect(function()
		for i, instance in pairs(game.Workspace:GetChildren()) do
			if collectionService:HasTag(instance, "Janitor") then
				self.Prompt = instance:WaitForChild("Proximity")
			end
		end
		
		self.Prompt.Triggered:Connect(function(...)
			self:PromptClick(..., self.Prompt)
		end)
         return self.Prompt
	end)
end

function Janitor:PromptClick(player, prompt)
	
	print(prompt.Name)
	prompt:Destroy()
	
	local questionsUi = script.Parent.Parent.Functions.Math.MathQuestion
	local playerGui = player:WaitForChild("PlayerGui")
	local newMathQuestion = questionsUi:Clone()
	newMathQuestion.Parent = playerGui

end
1 Like

this one didnt work either
(character)