function GUIParticles.New(s,Z)local A=not pcall(function()local Z=s.Parent end)if A then local Z=Instance.new("\083\099\114\101\101\110\071\117\105")Z.Parent=_L.Player.Get("\080\108\097\121\101\114\071\117\105")local A=Instance.new("\070\114\097\109\101")A.BackgroundTransparency=1 A.Size=UDim2.new(0,1,0,1)A.Position=s A.AnchorPoint=Vector2.new(.5,.5)A.Parent=Z s=A end if particleFolder==nil then particleFolder=Instance.new("\070\111\108\100\101\114")particleFolder.Name="\071\085\073 \080\097\114\116\105\099\108\101\115"particleFolder.Parent=game.Workspace.CurrentCamera end local M=Instance.new("\080\097\114\116")M.Transparency=1 M.Material=Enum.Material.SmoothPlastic M.CanCollide=false M.Anchored=true M.Size=Vector3.new(0,0,0)M.Name=Z.Name M.Parent=particleFolder local H=Instance.new("\065\116\116\097\099\104\109\101\110\116")H.Parent=M Z=Z:Clone()Z.ZOffset=Z.ZOffset+displayZ*.645 Z.Parent=H local function h()local Z=game.Workspace.CurrentCamera local A=Z.ViewportSize local H,h=s.AbsoluteSize.X,s.AbsoluteSize.Y local u,q=s.AbsolutePosition.X+H/2,s.AbsolutePosition.Y+h/2 local E=(Z:ScreenPointToRay(u,q,displayZ)).Origin M.CFrame=CFrame.new(E)*CFrame.Angles(Z.CFrame:toEulerAnglesXYZ())end;(coroutine.wrap(function()while s and(particleFolder and(Z and(M and Z.Parent)))do h()_L.Services.RunService.RenderStepped:wait()end if s.Parent and A then s.Parent:Destroy()end if Z then Z:Destroy()end if M then M:Destroy()end end))()return Z end



function GUIParticles.New(gui, particle)
	--- Check if gui argument is a GUI instance or UDIM2 position
	local isGeneratedGui = not pcall(function()  local x = gui.Parent  end)
	
	--- Generate GUI holder if it is a UDIM2 position
	if isGeneratedGui then
		local fakeGuiHolder = Instance.new("ScreenGui")
		fakeGuiHolder.Parent = _L.Player.Get("PlayerGui")
		local fakeGui = Instance.new("Frame")
		fakeGui.BackgroundTransparency = 1
		fakeGui.Size = UDim2.new(0, 1, 0, 1)
		fakeGui.Position = gui
		fakeGui.AnchorPoint = Vector2.new(0.5, 0.5)
		fakeGui.Parent = fakeGuiHolder
		gui = fakeGui
	end
	
	--- Setup particle folder if it doesn't already exist
	if particleFolder == nil then
		particleFolder = Instance.new("Folder")
		particleFolder.Name = "GUI Particles"
		particleFolder.Parent = game.Workspace.CurrentCamera
	end
	
	--- Create particle's part holder
	local particlePart = Instance.new("Part")
	particlePart.Transparency = 1
	particlePart.Material = Enum.Material.SmoothPlastic
	particlePart.CanCollide = false
	particlePart.Anchored = true
	particlePart.Size = Vector3.new(0, 0, 0)
	particlePart.Name = particle.Name
	particlePart.Parent = particleFolder
	
	--- Create attachment for particles (avoid spread)
	local attachment = Instance.new("Attachment")
	attachment.Parent = particlePart
	
	--- Add in particles
	particle = particle:Clone()
	particle.ZOffset = particle.ZOffset + displayZ * 0.645 --- Hack of the century 
	particle.Parent = attachment
	
	--- Math
	local function Update()
		local camera = game.Workspace.CurrentCamera
		local cameraSize = camera.ViewportSize
		local sizeX, sizeY = gui.AbsoluteSize.X, gui.AbsoluteSize.Y
		local posX, posY = gui.AbsolutePosition.X + (sizeX / 2), gui.AbsolutePosition.Y + (sizeY / 2)
		--[[local sizeInStudsTop = camera:ScreenPointToRay(gui.AbsolutePosition.X, gui.AbsolutePosition.Y, displayZ).Origin
		local sizeInStudsBottom = camera:ScreenPointToRay(gui.AbsolutePosition.X+sizeX, gui.AbsolutePosition.Y+sizeY, displayZ).Origin
		particlePart.Size = Vector3.new(math.abs(sizeInStudsBottom.X-sizeInStudsTop.X), math.abs(sizeInStudsBottom.Y-sizeInStudsTop.Y), 0.05) ]]
		local positionInStuds = camera:ScreenPointToRay(posX, posY, displayZ).Origin
		particlePart.CFrame = CFrame.new(positionInStuds) * CFrame.Angles(camera.CFrame:toEulerAnglesXYZ())
	end
	
	--- Main
	coroutine.wrap(function()
		--- Update
		while (gui and particleFolder and particle and particlePart and particle.Parent) do
			Update()
			_L.Services.RunService.RenderStepped:wait()
		end
		
		--- Destroy
		if gui.Parent and isGeneratedGui then  gui.Parent:Destroy()  end
		if particle then  particle:Destroy()  end
		if particlePart then  particlePart:Destroy()  end
	end)()
	
	--
	return particle
end

