local C=game:GetService("\067\111\108\108\101\099\116\105\111\110\083\101\114\118\105\099\101")local J=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local E=require(J.Shared.components)local l={Spinner=E.Spinner}local function f(J)local function f(C,l)local f=J:spawn(l(),E.Model({model=C}),E.Transform({cframe=C.PrimaryPart.CFrame}))C:SetAttribute("\115\101\114\118\101\114\069\110\116\105\116\121\073\100",f)end for E,l in pairs(l)do for C,J in ipairs(C:GetTagged(E))do f(J,l)end;(C:GetInstanceAddedSignal(E)):Connect(function(C)f(C,l)end);(C:GetInstanceRemovedSignal(E)):Connect(function(C)local E=C:GetAttribute("\115\101\114\118\101\114\069\110\116\105\116\121\073\100")if E then J:despawn(E)end end)end end return f
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Components = require(ReplicatedStorage.Shared.components)

local boundTags = {
	Spinner = Components.Spinner,
}

local function setupTags(world)
	local function spawnBound(instance, component)
		local id = world:spawn(
			component(),
			Components.Model({
				model = instance,
			}),
			Components.Transform({
				cframe = instance.PrimaryPart.CFrame,
			})
		)

		instance:SetAttribute("serverEntityId", id)
	end

	for tagName, component in pairs(boundTags) do
		for _, instance in ipairs(CollectionService:GetTagged(tagName)) do
			spawnBound(instance, component)
		end

		CollectionService:GetInstanceAddedSignal(tagName):Connect(function(instance)
			spawnBound(instance, component)
		end)

		CollectionService:GetInstanceRemovedSignal(tagName):Connect(function(instance)
			local id = instance:GetAttribute("serverEntityId")
			if id then
				world:despawn(id)
			end
		end)
	end
end

return setupTags
