I’ve been making a dialogue system for my game. I plan to make it so that every proximityprompt with a certain value “Dialogue” in it will trigger a RemoteEvent upon use.
Is there any way to make a serverscript that can listen to all these prompts to check when they’ve been triggered? Is it fine to just put a script for every individual prompt? That just feels unoptimized.
This is mainly an architecture question, so any other ways of implementing this could help a lot!
The CollectionService is an alternative to putting a script in many objects. Tag all of the ProximityPrompt objects with “Dialogue” and then this code will run ProcessPrompt for each object with that tag.
local CollectionService = game:GetService("CollectionService")
local function ProcessPrompt(part)
-- Code which runs for each ProximityPrompt
end
for _,part in CollectionService:GetTagged("Dialogue") do
ProcessPrompt(part)
end
CollectionService:GetInstanceAddedSignal("Dialog"):Connect(ProcessPrompt)