Загрузка данных


-- made by s4mo
--11.09.26
-- crusher

local mesh = script.Parent
local prompt = mesh:WaitForChild("ProximityPrompt") 
local alreadyStarted = false

local function startChaos()
	if alreadyStarted then return end
	alreadyStarted = true

	prompt.Enabled = false 

	local soundGroup = Instance.new("SoundGroup")
	soundGroup.Volume = 10
	soundGroup.Parent = game:GetService("SoundService")

	local sound = Instance.new("Sound")
	sound.SoundId = "rbxassetid://109263303377273"
	sound.Volume = 10
	sound.SoundGroup = soundGroup
	sound.Parent = mesh
	sound:Play()

	local rotationSpeed = 100 
	local spinConnection
	spinConnection = game:GetService("RunService").Heartbeat:Connect(function(dt)
		if mesh and mesh.Parent then
			mesh.CFrame = mesh.CFrame * CFrame.Angles(0, rotationSpeed * dt, 0)
		else
			spinConnection:Disconnect()
		end
	end)

	local totalToSpawn = 1000
	local duration = 3
	local ratePerSecond = totalToSpawn / duration
	local spawnedCount = 0

	local spawnConnection
	spawnConnection = game:GetService("RunService").Heartbeat:Connect(function(dt)
		local toSpawnThisFrame = math.floor(ratePerSecond * dt)

		for i = 1, toSpawnThisFrame do
			if spawnedCount >= totalToSpawn then
				spawnConnection:Disconnect() 
				break
			end

			local clone = mesh:Clone()

			for _, child in ipairs(clone:GetChildren()) do
				if child:IsA("Script") or child:IsA("LocalScript") or child:IsA("ProximityPrompt") or child:IsA("Sound") then
					child:Destroy()
				end
			end

			clone.Color = Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255))

			clone.Position = mesh.Position + Vector3.new(
				math.random(-50, 50) / 100, 
				math.random(10, 50) / 100,  
				math.random(-50, 50) / 100
			)

			clone.Parent = workspace
			spawnedCount = spawnedCount + 1
		end
	end)
end

prompt.Triggered:Connect(startChaos)