I made this 3D confeti particle script

Looking for feedback!

local ConfetiCount = 40

for a = 1, ConfetiCount do
    local Confeti = Instance.new("Part")
    Confeti.Size = Vector3.new(0.8, 0, 0.3)
    Confeti.Material = Enum.Material.SmoothPlastic
    Confeti.CanCollide = false
    Confeti.Position = script.Parent.Position
    Confeti.CastShadow = false
    
    local RandomColor = math.random(1,6)
    
    if RandomColor == 1 then
        Confeti.Color = Color3.new(1, 0, 0)
    elseif RandomColor == 2 then
        Confeti.Color = Color3.new(0, 1, 0)
    elseif RandomColor == 3 then
        Confeti.Color = Color3.new(0, 0, 1)
    elseif RandomColor == 4 then
        Confeti.Color = Color3.new(0, 1, 1)
    elseif RandomColor == 5 then
        Confeti.Color = Color3.new(1, 1, 0)
    elseif RandomColor == 6 then
        Confeti.Color = Color3.new(1, 0, 1)
    end
    
    local ConfetiBV = Instance.new("BodyVelocity",Confeti)
    local ConfetiBAV = Instance.new("BodyAngularVelocity",Confeti)
    
    ConfetiBV.MaxForce = Vector3.new(1,1,1)*math.huge
    ConfetiBAV.MaxTorque = Vector3.new(1,1,1)*math.huge
    
    ConfetiBV.Velocity = Vector3.new(math.random(-100,100),math.random(70,100),math.random(-100,100))
    ConfetiBAV.AngularVelocity = Vector3.new(math.random(-15,15),math.random(-15,15),math.random(-15,15))
    
    Confeti.Parent = workspace
    
    game:GetService("TweenService"):Create(ConfetiBV, TweenInfo.new(1,Enum.EasingStyle.Exponential),{Velocity = Vector3.new(0,-5,0)}):Play()
    
    task.delay(3,function()
        if Confeti then
            game:GetService("TweenService"):Create(Confeti,TweenInfo.new(1),{Transparency = 1}):Play()
            task.delay(1,function()
                if Confeti then
                    Confeti:Destroy()
                end
            end)
        end
    end)
end
3 Likes

Super fun script:> good job. I tried making it launch Traffic Cones. Here’s your code changed a bit if you wanna check it out:> just a little change

local ConfetiCount = 40
local IS = game:GetService("InsertService")

for a = 1, ConfetiCount do
	local TempTrafficCone = IS:LoadAsset(23153487)
	TempTrafficCone.Parent = game.ReplicatedStorage
	TempTrafficCone.Name = "TrafficConeHold"
	
	local TrafficCone = game.ReplicatedStorage:FindFirstChild("TrafficConeHold"):FindFirstChild("Traffic Cone"):Clone()
	TrafficCone.Size = Vector3.new(1.2, 0.1, 1.2)
	TrafficCone.Material = Enum.Material.SmoothPlastic
	TrafficCone.CanCollide = false
	TrafficCone.Transparency = 0
	TrafficCone.Position = script.Parent.Position
	TrafficCone.CastShadow = true

	local ConfetiBV = Instance.new("BodyVelocity",TrafficCone)
	local ConfetiBAV = Instance.new("BodyAngularVelocity",TrafficCone)

	ConfetiBV.MaxForce = Vector3.new(1,1,1)*math.huge
	ConfetiBAV.MaxTorque = Vector3.new(1,1,1)*math.huge

	ConfetiBV.Velocity = Vector3.new(math.random(-100,100),math.random(70,100),math.random(-100,100))
	ConfetiBAV.AngularVelocity = Vector3.new(math.random(-15,15),math.random(-15,15),math.random(-15,15))

	TrafficCone.Parent = workspace

	game:GetService("TweenService"):Create(ConfetiBV, TweenInfo.new(1,Enum.EasingStyle.Exponential),{Velocity = Vector3.new(0,-5,0)}):Play()

	task.delay(3,function()
		if TrafficCone then
			game:GetService("TweenService"):Create(TrafficCone,TweenInfo.new(1),{Transparency = 1}):Play()
			task.delay(1,function()
				if TrafficCone then
					TrafficCone:Destroy()
					TempTrafficCone:Destroy()
				end
			end)
		end
	end)
end
3 Likes