local C=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local J=require(C.Shared.components)local E=require(C.Lib.Matter)local function l(C)for l,f,T,w in C:query(J.Model,J.Lasering,J.Transform,J.Mothership)do f.model.Beam.Transparency=1-T.remainingTime T=T:patch({remainingTime=T.remainingTime-E.useDeltaTime()})if not T.spawned then local E=Vector3.new(w.cframe.p.X,11,w.cframe.p.Z)C:spawn(J.Roomba(),J.Charge({charge=100}),J.Transform({cframe=CFrame.new(E)}))T=T:patch({spawned=true})end if T.remainingTime<=0 then C:remove(l,J.Lasering)else C:insert(l,T)end end end return l
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Components = require(ReplicatedStorage.Shared.components)
local Matter = require(ReplicatedStorage.Lib.Matter)

local function mothershipsSpawnRoombas(world)
	for id, model, lasering, transform in
		world:query(Components.Model, Components.Lasering, Components.Transform, Components.Mothership)
	do
		model.model.Beam.Transparency = 1 - lasering.remainingTime

		lasering = lasering:patch({
			remainingTime = lasering.remainingTime - Matter.useDeltaTime(),
		})

		if not lasering.spawned then
			local spawnPosition = Vector3.new(transform.cframe.p.X, 11, transform.cframe.p.Z)

			world:spawn(
				Components.Roomba(),
				Components.Charge({
					charge = 100,
				}),
				Components.Transform({
					cframe = CFrame.new(spawnPosition),
				})
			)

			lasering = lasering:patch({ spawned = true })
		end

		if lasering.remainingTime <= 0 then
			world:remove(id, Components.Lasering)
		else
			world:insert(id, lasering)
		end
	end
end

return mothershipsSpawnRoombas
