I am trying to figure out CollectionService and how i could make it work for multiple parts and i came up with this.
Is there anything to improve? Or is this the correct way to use it?
local __CS = game:GetService("CollectionService")
local __CONNECTIONS = {}
function StartProm(__INST:BasePart?)
__CONNECTIONS[__INST] = {}
table.insert(__CONNECTIONS[__INST], __INST:FindFirstChildOfClass("ProximityPrompt").TriggerEnded:Connect(function(__PLR)
print(__PLR.Name)
end))
end
local __VENDING = __CS:GetTagged("__VNDMCHN")
for count=1, #__VENDING do
local __INT = __VENDING[count]
StartProm(__INT)
end
-- TAG HANDLER APPLIER
for _,v in ipairs(workspace:GetChildren()) do
if v.Name == "__VENDMACHINE" then
__CS:AddTag(v, "__VNDMCHN")
end
end