Hey, I’ve got a table with proximity prompts in it (each are supposed to do different things). Is there a way of detecting if any of those proximity prompts have been triggered (in the table) and if so, which one was triggered?
I think this would be a lot tidier than it being in separate scripts and I’m sure there is a way to do it, just not sure how.
local prompts = workspace:WaitForChild("PromptFolder"):GetDescendants()
for _, prompt in ipairs(prompts) do
if prompt:IsA("ProximityPromot") then
prompt.Triggered:Connect(function()
print(prompt.Parent.Name)
local part = prompt.Parent
--do more stuff here
end)
end
end
Basically, just have the prompts and their parents all in a single folder than use the above to connect the same or potentially different callback functions to each, through which you can determine which prompt has been triggered when any prompt has been triggered.