local G={}G.__index=G local r=Vector2.new(0,.85)function G.setGravity(G)r=G end function G.createParticle(r,t,q)local y={}setmetatable(y,G)local f=t.X if f<0 then f=f*-1 end local k=0-f t=Vector2.new(t.X,t.Y+k*.75)y.EmitterPosition=r y.EmitterPower=t y.Position=Vector2.new(0,0)y.Power=t y.Color=getColor()local function z()local G=shapes[math.random(#shapes)]:Clone()G.Size=UDim2.new(y.DefaultSize,0,y.DefaultSize,0)G.ImageColor3=y.Color G.Parent=q G.Rotation=math.random(360)G.Visible=true G.ZIndex=100 return G end y.DefaultSize=math.random(1,2)/20 y.Label=z()y.Size=1 y.Side=-1 y.OutOfBounds=false y.Enabled=true y.Cycles=0 return y end function G.Update(G)if G.Enabled and G.OutOfBounds then G.Position=Vector2.new(0,0)G.Power=Vector2.new((G.EmitterPower.X+math.random(10))-5,(G.EmitterPower.Y+math.random(10))-5)G.Cycles=G.Cycles+1 end if not G.Enabled and G.OutOfBounds then return end local t,q,y=G.EmitterPosition,G.Position,G.Power local f=G.Label if f then local k=Vector2.new(q.X-y.X,q.Y-y.Y)local z=Vector2.new(y.X/1.09-r.X,y.Y/1.1-r.Y)local N=Camera.ViewportSize f.Position=UDim2.new(t.X,k.X,t.Y,k.Y)G.OutOfBounds=f.AbsolutePosition.X>N.X and r.X>0 or f.AbsolutePosition.Y>N.Y and r.Y>0 or f.AbsolutePosition.X<0 and r.X<0 or f.AbsolutePosition.Y<0 and r.Y<0 G.Position,G.Power=k,z end end function G.Toggle(G)G.Enabled=not G.Enabled end return G

local _Confetti = {} _Confetti.__index = _Confetti

	-- Set Gravity --
	local gravity = Vector2.new(0,0.85)
	function _Confetti.setGravity(paramVec2)
		gravity = paramVec2
	end
	
	-- Create A Confetti Particle --	
	function _Confetti.createParticle(paramEmitter, paramForce, paramParent)
		
		local _Particle = {} setmetatable(_Particle, _Confetti)

		local xforce = paramForce.X if (xforce < 0) then xforce = xforce * -1 end
		local distanceFromZero = 0 - xforce
		paramForce = Vector2.new(paramForce.X, paramForce.Y + (distanceFromZero * 0.75))
			
		_Particle.EmitterPosition = paramEmitter
		_Particle.EmitterPower = paramForce
		_Particle.Position = Vector2.new(0,0)
		_Particle.Power = paramForce
		_Particle.Color = getColor()
		
		local function getParticle()
			local label = shapes[math.random(#shapes)]:Clone()
			label.Size = UDim2.new(_Particle.DefaultSize, 0, _Particle.DefaultSize, 0)	
			label.ImageColor3 = _Particle.Color
			label.Parent = paramParent
			label.Rotation = math.random(360)
			label.Visible = true
			label.ZIndex = 100
			return label
		end
		
		_Particle.DefaultSize = (math.random(1,2))/20
		_Particle.Label = getParticle()
		_Particle.Size = 1 
		_Particle.Side = -1
		_Particle.OutOfBounds = false
		_Particle.Enabled = true
		_Particle.Cycles = 0	
		
		return _Particle
	end
	
	-- Update Postion Of Confettis --
	function _Confetti:Update()
		if (self.Enabled and self.OutOfBounds) then
			self.Position = Vector2.new(0,0)
			self.Power = Vector2.new(self.EmitterPower.X + math.random(10)-5, self.EmitterPower.Y + math.random(10)-5)
			self.Cycles = self.Cycles + 1
		end	
		if (not(self.Enabled) and self.OutOfBounds) then
			return
		end
		local startPosition, currentPosition, currentPower = self.EmitterPosition, self.Position, self.Power
		local imageLabel = self.Label
		
		if (imageLabel) then

			local newPosition = Vector2.new(currentPosition.X - currentPower.X, currentPosition.Y - currentPower.Y)
			local newPower = Vector2.new((currentPower.X/1.09) - gravity.X, (currentPower.Y/1.1) - gravity.Y)
			local ViewportSize = Camera.ViewportSize
			imageLabel.Position = UDim2.new(startPosition.X, newPosition.X, startPosition.Y, newPosition.Y)
			self.OutOfBounds = 
				(imageLabel.AbsolutePosition.X > ViewportSize.X and gravity.X > 0) or
				(imageLabel.AbsolutePosition.Y > ViewportSize.Y and gravity.Y > 0) or
				(imageLabel.AbsolutePosition.X < 0  and gravity.X < 0) or
				(imageLabel.AbsolutePosition.Y < 0 and gravity.Y < 0)
			self.Position, self.Power = newPosition, newPower
			
			--[[
			if (newPower.Y < 0) then
				if (self.Size <= 0) then
					self.Side = 1
					imageLabel.ImageColor3 = self.Color
				end
				if (self.Size >= self.DefaultSize) then 
					self.Side = -1
					imageLabel.ImageColor3 = Color3.new(self.Color.r * 0.65, self.Color.g * 0.65, self.Color.b * 0.65)
				end
			end
			--]]
		end
	end
	
	-- Stops Confetti --
	function _Confetti:Toggle()
		self.Enabled = not(self.Enabled)
	end
	
return _Confetti
