Is there a way to make drag detector work for every object with a tag?

For example, I want to make a simple grab system, and I want to use Drag Detector for that.
But what can I do to prevent putting Drag Detector in every part that I want to be grabbable?

Can I use Tags for that? and if I can, Please explain me how

Yes, you can use Tags for that, which would use CollectionService.

CollectionService - Documentation

local CollectionService = game:GetService('CollectionService')
local Tag = 'Draggable'

for _, v in pairs(CollectionService:GetTagged(Tag)) do
	local DragDetector = Instance.new('DragDetector')
	
	DragDetector.Parent = v
end

Thanks a lot, you saved my game :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.