function randUniform(W,m)return W+math.random()*(m-W)end function randVector(W,m)return Vector3.new(randUniform(W.x,m.x),randUniform(W.y,m.y),randUniform(W.z,m.z))end TriggerEffect.Event:Connect(function()local W=CollectionService:GetTagged("\098\108\111\120")script.Parent.PointLight:SetAttribute("\083\112\097\119\110\084\105\109\101",workspace.DistributedGameTime)verticalBeamPS:SetAttribute("\083\112\097\119\110\084\105\109\101",workspace.DistributedGameTime)plasmaBeamA:SetAttribute("\083\112\097\119\110\084\105\109\101",workspace.DistributedGameTime)plasmaBeamB:SetAttribute("\083\112\097\119\110\084\105\109\101",workspace.DistributedGameTime)dustParticles:Emit(15)flashPS:Emit(1)shockwave:Emit(1)verticalBeamPS:Emit(8)verticalBeamPS.Enabled=true bloxParticles:Emit(100)plasmaBeamA.Enabled=true plasmaBeamB.Enabled=true if#W<maxBlox then for W=-1,1,1 do for m=-1,1,1 do for O=-1,1,1 do local q=blox:Clone()q.Transparency=0 q.Parent=workspace q.Position=bloxSpawnLoc.Position+Vector3.new(W*(blox.Size.x+spacing),m*(blox.Size.y+spacing),O*(blox.Size.z+spacing))q.Anchored=false q:ApplyImpulse(randVector(Vector3.new(-hSpeed,0,-hSpeed),Vector3.new(hSpeed,vSpeed,hSpeed)))q:ApplyAngularImpulse(randVector(Vector3.new(-0.0005,-0.0005,-0.0005),Vector3.new(.0005,.0005,.0005)))q:SetAttribute("\073\068",math.random())q:SetAttribute("\083\112\097\119\110\084\105\109\101",workspace.DistributedGameTime)q:SetAttribute("\076\105\102\101\116\105\109\101",randUniform(2.0,3.0))CollectionService:AddTag(q,"\098\108\111\120")end end end end end)

function randUniform(a, b)
	return a + math.random() * (b - a)
end

function randVector(a, b)
	return Vector3.new(randUniform(a.x, b.x), randUniform(a.y, b.y), randUniform(a.z, b.z))
end


TriggerEffect.Event:Connect(function()
	local liveBlox = CollectionService:GetTagged("blox")
	script.Parent.PointLight:SetAttribute("SpawnTime", workspace.DistributedGameTime)
	verticalBeamPS:SetAttribute("SpawnTime", workspace.DistributedGameTime)
	plasmaBeamA:SetAttribute("SpawnTime", workspace.DistributedGameTime)
	plasmaBeamB:SetAttribute("SpawnTime", workspace.DistributedGameTime)

	dustParticles:Emit(15)
	flashPS:Emit(1)
	shockwave:Emit(1)
	verticalBeamPS:Emit(8)
	verticalBeamPS.Enabled = true

	bloxParticles:Emit(100)

	plasmaBeamA.Enabled = true
	plasmaBeamB.Enabled = true

	if #liveBlox < maxBlox then
		for i = -1, 1, 1 do
			for j = -1, 1, 1 do
				for k = -1, 1, 1 do
					local bloxInstance = blox:Clone()
					bloxInstance.Transparency = 0
					bloxInstance.Parent = workspace

					bloxInstance.Position = bloxSpawnLoc.Position + Vector3.new(i * (blox.Size.x + spacing), j * (blox.Size.y + spacing), k * (blox.Size.z + spacing))

					bloxInstance.Anchored = false
					bloxInstance:ApplyImpulse(randVector(Vector3.new(-hSpeed, 0, -hSpeed), Vector3.new(hSpeed, vSpeed, hSpeed)))
					bloxInstance:ApplyAngularImpulse(randVector(Vector3.new(-0.0005, -0.0005, -0.0005), Vector3.new(0.0005, 0.0005, 0.0005)))

					bloxInstance:SetAttribute("ID", math.random())
					bloxInstance:SetAttribute("SpawnTime", workspace.DistributedGameTime)
					bloxInstance:SetAttribute("Lifetime", randUniform(2.0, 3.0))


					CollectionService:AddTag(bloxInstance, "blox")
				end
			end
		end
	end
end)
