local l=script:WaitForChild("\099\114\101\097\116\101\084\114\097\105\108")l.OnServerEvent:connect(function(l,u,V,p,n)local h=Instance.new("\080\097\114\116")h.BrickColor=n.trailSettings.Color h.Transparency=n.trailSettings.Transparency h.Anchored=true h.CanCollide=false h.Size=V3(1,1,1)local T=Instance.new("\067\121\108\105\110\100\101\114\077\101\115\104")T.Offset=V3(0,-(V-u).magnitude/2,0)T.Scale=V3(n.trailSettings.Thickness,(V-u).magnitude,n.trailSettings.Thickness)T.Parent=h h.Parent=p h.CFrame=CF(u,V)*CFANG(RAD(90),0,0)delay(n.trailSettings.visibleTime,function()if n.trailSettings.disappearTime>0 then local l=tick()while true do local u=math.min((tick()-l)/n.trailSettings.disappearTime,1)h.Transparency=numLerp(n.trailSettings.Transparency,1,u)if u==1 then break end wait()end h:Destroy()else h:Destroy()end end)end)
----------------------------------------------------------------------
--------------------[ TRAIL HANDLING ]--------------------------------
----------------------------------------------------------------------

local createTrail = script:WaitForChild("createTrail")
createTrail.OnServerEvent:connect(function(_, Origin, P, gunIgnore, S)
	local Trail = Instance.new("Part")
	Trail.BrickColor = S.trailSettings.Color
	Trail.Transparency = S.trailSettings.Transparency
	Trail.Anchored = true
	Trail.CanCollide = false
	Trail.Size = V3(1, 1, 1)
	local Mesh = Instance.new("CylinderMesh")
	Mesh.Offset = V3(0, -(P - Origin).magnitude / 2, 0)
	Mesh.Scale = V3(S.trailSettings.Thickness, (P - Origin).magnitude, S.trailSettings.Thickness)
	Mesh.Parent = Trail
	Trail.Parent = gunIgnore
	Trail.CFrame = CF(Origin, P) * CFANG(RAD(90), 0, 0)
	delay(S.trailSettings.visibleTime, function()
		if S.trailSettings.disappearTime > 0 then
			local t0 = tick()
			while true do
				local Alpha = math.min((tick() - t0) / S.trailSettings.disappearTime, 1)
				Trail.Transparency = numLerp(S.trailSettings.Transparency, 1, Alpha)
				if Alpha == 1 then
					break
				end
				wait()
			end
			Trail:Destroy()
		else
			Trail:Destroy()
		end
	end)
end)
