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
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